Skip to content

Commit

Permalink
churn: fix duplicate organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Jan 26, 2024
1 parent a64dd1d commit 7b2ff71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion otterdog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _execute_operation(organizations: list[str], operation: Operation):
# if no organization has been specified as argument,
# process all organizations found in the configuration.
if len(organizations) == 0:
organizations = list(config.organization_configs.keys())
organizations = config.organization_names

for organization in organizations:
org_config = config.get_organization_config(organization)
Expand Down
16 changes: 11 additions & 5 deletions otterdog/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ def __init__(self, config_file: str, local_mode: bool, working_dir: Optional[str

organizations = self._configuration.get("organizations", [])

self._organizations = {}
self._organizations_map = {}
self._organizations = []
for org in organizations:
org_config = OrganizationConfig.from_dict(org, self)
self._organizations[org_config.name] = org_config
self._organizations[org_config.github_id] = org_config
self._organizations.append(org_config)
self._organizations_map[org_config.name] = org_config
self._organizations_map[org_config.github_id] = org_config

@property
def config_file(self) -> str:
Expand All @@ -168,10 +170,14 @@ def default_base_template(self) -> str:

@property
def organization_configs(self) -> dict[str, OrganizationConfig]:
return self._organizations
return self._organizations_map

@property
def organization_names(self) -> list[str]:
return list(map(lambda config: config.name, self._organizations))

def get_organization_config(self, organization_name: str) -> OrganizationConfig:
org_config = self._organizations.get(organization_name)
org_config = self._organizations_map.get(organization_name)
if org_config is None:
raise RuntimeError(f"unknown organization with name / github_id '{organization_name}'")
return org_config
Expand Down

0 comments on commit 7b2ff71

Please sign in to comment.