Skip to content

Commit

Permalink
Merge pull request #180 from 3rd-party-integrations/primetheus/group-…
Browse files Browse the repository at this point in the history
…prefix

Add ability to filter based on group prefixes
  • Loading branch information
primetheus authored Sep 4, 2023
2 parents f246471 + c4bed62 commit 8fcb9f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ def sync_team(client=None, owner=None, team_id=None, slug=None):
try:
org = client.organization(owner)
team = org.team(team_id)
custom_map, ignore_users = load_custom_map()
custom_map, group_prefix, ignore_users = load_custom_map()
try:
directory_group = get_directory_from_slug(slug, custom_map, org)
# If we're filtering on group prefix, skip if the group doesn't match
if group_prefix.length() > 0 and not directory_group.startswith(
tuple(group_prefix)
):
print(f"skipping team {team.slug} - not in group prefix")
return
directory_members = directory_group_members(group=directory_group)
except Exception as e:
directory_members = []
Expand Down Expand Up @@ -260,10 +266,10 @@ def load_custom_map(file="syncmap.yml"):
syncmap[(d["org"], d["github"])] = d["directory"]
else:
syncmap[d["github"]] = d["directory"]

group_prefix = data.get("group_prefix", [])
ignore_users = data.get("ignore_users", [])

return (syncmap, ignore_users)
return (syncmap, group_prefix, ignore_users)


def get_app_installations():
Expand Down
5 changes: 5 additions & 0 deletions syncmap.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ mapping:
org: demo-org
directory: avengers group

# Only sync groups with matching prefixes
#group_prefix:
# - TEST-
# - DEMO-

ignore_users:
- userA
- userB
Expand Down

0 comments on commit 8fcb9f1

Please sign in to comment.