Skip to content

Commit

Permalink
introduce default settings, first for team creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmehl committed Aug 21, 2024
1 parent 4205a64 commit 0de01b9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions config/example/org.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ org_name: example-org-on-github
# List of owners of the GitHub organisation
org_owners:
- octocat

# Default settings
defaults:
team:
# Level of privacy of a team. Can be "secret" or "closed"
privacy: "closed"
12 changes: 10 additions & 2 deletions gh_org_mgr/_gh_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class GHorg: # pylint: disable=too-many-instance-attributes
gh: Github = None # type: ignore
org: Organization = None # type: ignore
gh_token: str = ""
default_settings: dict[str, dict[str, str]] = field(default_factory=dict)
default_repository_permission: str = ""
current_org_owners: list[NamedUser] = field(default_factory=list)
configured_org_owners: list[str] = field(default_factory=list)
Expand Down Expand Up @@ -163,12 +164,19 @@ def create_missing_teams(self, dry: bool = False):

logging.info("Creating team '%s' with parent ID '%s'", team, parent_id)
if not dry:
self.org.create_team(team, parent_team_id=parent_id)
self.org.create_team(
team,
parent_team_id=parent_id,
# Hardcode privacy as "secret" is not possible in child teams
privacy="closed",
)

else:
logging.info("Creating team '%s' without parent", team)
if not dry:
self.org.create_team(team, privacy="closed")
self.org.create_team(
team, privacy=self.default_settings.get("team", {}).get("privacy", "")
)

else:
logging.debug("Team '%s' already exists", team)
Expand Down
3 changes: 2 additions & 1 deletion gh_org_mgr/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def main():
"No GitHub organisation name configured in organisation settings. Cannot continue"
)
sys.exit(1)
org.configured_org_owners = cfg_org.get("org_owners")
org.configured_org_owners = cfg_org.get("org_owners", [])
org.default_settings = cfg_org.get("defaults", {})

# Login to GitHub with token, get GitHub organisation
org.login(cfg_org.get("org_name", ""), cfg_app.get("github_token", ""))
Expand Down

0 comments on commit 0de01b9

Please sign in to comment.