From 30b8d7b0909dc79195b8e22b676348e4a01d1bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 6 Nov 2023 07:46:07 +0100 Subject: [PATCH] Configurator: make sure all config values have defaults set before hand --- buildbot_nix/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/buildbot_nix/__init__.py b/buildbot_nix/__init__.py index 3004f91..a7aad52 100644 --- a/buildbot_nix/__init__.py +++ b/buildbot_nix/__init__.py @@ -719,7 +719,11 @@ class NixConfigurator(ConfiguratorBase): projects = [p for p in projects if self.github.topic in p.topics] worker_config = json.loads(read_secret_file(self.nix_workers_secret_name)) worker_names = [] - config["workers"] = config.get("workers", []) + + config.setdefault("projects", []) + config.setdefault("secretsProviders", []) + config.setdefault("www", {}) + for item in worker_config: cores = item.get("cores", 0) for i in range(cores): @@ -727,8 +731,6 @@ class NixConfigurator(ConfiguratorBase): config["workers"].append(worker.Worker(worker_name, item["pass"])) worker_names.append(worker_name) - config["projects"] = config.get("projects", []) - webhook_secret = read_secret_file(self.github.webhook_secret_name) for project in projects: @@ -775,7 +777,6 @@ class NixConfigurator(ConfiguratorBase): ), ] ) - config["services"] = config.get("services", []) config["services"].append( reporters.GitHubStatusPush( token=self.github.token(), @@ -788,9 +789,7 @@ class NixConfigurator(ConfiguratorBase): systemd_secrets = secrets.SecretInAFile( dirname=os.environ["CREDENTIALS_DIRECTORY"] ) - config["secretsProviders"] = config.get("secretsProviders", []) config["secretsProviders"].append(systemd_secrets) - config["www"] = config.get("www", {}) config["www"]["change_hook_dialects"] = config["www"].get( "change_hook_dialects", {} )