From 02598fa3bcbeb3ef37980a7c744c51310a799895 Mon Sep 17 00:00:00 2001 From: Max Erenberg <> Date: Sun, 2 Jan 2022 22:43:22 -0500 Subject: [PATCH] allow ignored Harbor projects to be configurable --- ceo_common/model/Config.py | 4 +++- ceod/model/ContainerRegistryService.py | 6 ++---- etc/ceod.ini | 1 + tests/ceod_dev.ini | 1 + tests/ceod_test_local.ini | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ceo_common/model/Config.py b/ceo_common/model/Config.py index dfe7bbc..63f6de3 100644 --- a/ceo_common/model/Config.py +++ b/ceo_common/model/Config.py @@ -27,6 +27,8 @@ class Config: return True if val.lower() in ['false', 'no']: return False - if section.startswith('auxiliary ') or section == 'positions': + # We should do something about this... + if section.startswith('auxiliary ') or section == 'positions' or \ + (section == 'registry' and key == 'projects_to_ignore'): return [item.strip() for item in val.split(',')] return val diff --git a/ceod/model/ContainerRegistryService.py b/ceod/model/ContainerRegistryService.py index c921905..24682a9 100644 --- a/ceod/model/ContainerRegistryService.py +++ b/ceod/model/ContainerRegistryService.py @@ -19,6 +19,7 @@ class ContainerRegistryService: api_username = cfg.get('registry_username') api_password = cfg.get('registry_password') self.basic_auth = HTTPBasicAuth(api_username, api_password) + self.projects_to_ignore = cfg.get('registry_projects_to_ignore') def _http_request(self, method: str, path: str, **kwargs): return requests.request( @@ -45,12 +46,9 @@ class ContainerRegistryService: # we're actually just going to get a list of projects resp = self._http_get('/projects') resp.raise_for_status() - # This project is only owned by the admin account, so we don't - # want to include it - project_exceptions = ['library'] return [ project['name'] for project in resp.json() - if project['name'] not in project_exceptions + if project['name'] not in self.projects_to_ignore ] def create_project_for_user(self, username: str): diff --git a/etc/ceod.ini b/etc/ceod.ini index fe48955..1a738a3 100644 --- a/etc/ceod.ini +++ b/etc/ceod.ini @@ -105,3 +105,4 @@ server_url = https://172.19.134.149:6443 base_url = https://registry.cloud.csclub.uwaterloo.ca/api/v2.0 username = REPLACE_ME password = REPLACE_ME +projects_to_ignore = library, openwhisk diff --git a/tests/ceod_dev.ini b/tests/ceod_dev.ini index 1401700..86633da 100644 --- a/tests/ceod_dev.ini +++ b/tests/ceod_dev.ini @@ -99,3 +99,4 @@ server_url = https://172.19.134.149:6443 base_url = http://localhost:8002/api/v2.0 username = REPLACE_ME password = REPLACE_ME +projects_to_ignore = library,openwhisk diff --git a/tests/ceod_test_local.ini b/tests/ceod_test_local.ini index 2102bdb..0171a4f 100644 --- a/tests/ceod_test_local.ini +++ b/tests/ceod_test_local.ini @@ -98,3 +98,4 @@ server_url = https://172.19.134.149:6443 base_url = http://localhost:8002/api/v2.0 username = REPLACE_ME password = REPLACE_ME +projects_to_ignore = library, openwhisk