Skip to content

Commit 2efd944

Browse files
Readme updates and a bit of housekeeping
1 parent 8ba0300 commit 2efd944

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ dist
1515
tox.ini
1616
test-reports/*
1717
config.json
18+
.eggs/

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
include requirements.txt
22
include requirements.in
33
include repokid/py.typed
4+
5+
include LICENSE README.md
6+
7+
global-exclude *.py[cod]

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To run locally:
3939

4040
If you run the development version the table and index will be created for you automatically.
4141

42-
#### IAM Permissions:
42+
#### IAM Permissions
4343

4444
Repokid needs an IAM Role in each account that will be queried. Additionally, Repokid needs to be launched with a role or user which can `sts:AssumeRole` into the different account roles.
4545

@@ -131,11 +131,15 @@ By default the age filter excludes roles that are younger than 90 days. To chan
131131
`filter_config.AgeFilter.minimum_age`.
132132

133133
### Active Filters
134+
134135
New filters can be created to support internal logic. At Netflix we have several that are specific to our
135136
use cases. To make them active make sure they are in the Python path and add them in the config to the list in
136137
the section `active_filters`.
137138

138-
## Hooks
139+
## Extending Repokid
140+
141+
### Hooks
142+
139143
Repokid is extensible via hooks that are called before, during, and after various operations as listed below.
140144

141145
| Hook name | Context |
@@ -147,8 +151,52 @@ Repokid is extensible via hooks that are called before, during, and after variou
147151
| `DURING_REPOABLE_CALCULATION` | role_id, account_number, role_name, potentially_repoable_permissions, minimum_age |
148152
| `DURING_REPOABLE_CALCULATION_BATCH` | role_batch, potentially_repoable_permissions, minimum_age |
149153

154+
Hooks must adhere to the following interface:
155+
156+
```python
157+
from repokid.hooks import implements_hook
158+
from repokid.types import RepokidHookInput, RepokidHookOutput
159+
160+
@implements_hook("TARGET_HOOK_NAME", 1)
161+
def custom_hook(input_dict: RepokidHookInput) -> RepokidHookOutput:
162+
"""Hook functions are called with a dict containing the keys listed above based on the target hook.
163+
Any mutations made to the input and returned in the output will be passed on to subsequent hook funtions.
164+
"""
165+
...
166+
```
167+
150168
Examples of hook implementations can be found in [`repokid.hooks.loggers`](repokid/hooks/loggers/__init__.py).
151169

170+
### Filters
171+
172+
Custom filters can be written to exclude roles from being repoed. Filters must adhere to the following interface:
173+
174+
```python
175+
from repokid.filters import Filter
176+
from repokid.types import RepokidFilterConfig
177+
from repokid.role import RoleList
178+
179+
180+
class CustomFilterName(Filter):
181+
def __init__(self, config: RepokidFilterConfig = None) -> None:
182+
"""Filters are initialized with a dict containing the contents of `filter_config.FilterName`
183+
from the config file. This example would be initialized with `filter_config.CustomFilterName`.
184+
The configuration can be accessed via `self.config`
185+
186+
If you don't need any custom initialization logic, you can leave this function out of your
187+
filter class.
188+
"""
189+
super().__init__(config=config)
190+
# custom initialization logic goes here
191+
...
192+
193+
def apply(self, input_list: RoleList) -> RoleList:
194+
"""Determine roles to be excluded and return them as a RoleList"""
195+
...
196+
```
197+
198+
A simple filter implementation can be found in [`repokid.filters.age`](repokid/filters/age/__init__.py). A more complex example is in [`repokid.blocklist.age`](repokid/filters/blocklist/__init__.py).
199+
152200
## How to Use
153201

154202
Once Repokid is configured, use it as follows:

0 commit comments

Comments
 (0)