aboutsummaryrefslogtreecommitdiff
path: root/labbot
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-09-09 12:53:21 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-09-09 12:53:21 +0200
commit78f3ee84bcb1164b0260325d42fe7ef96c034ed0 (patch)
tree725348ba937b7f2e8c455398d7905a3f873b38a7 /labbot
parent7021fbbd7fca1d4e505c193cebaecba67e62bf35 (diff)
downloadlab-bot-78f3ee84bcb1164b0260325d42fe7ef96c034ed0.tar.gz
lab-bot-78f3ee84bcb1164b0260325d42fe7ef96c034ed0.zip
always keep the dynamic config above the static config
Diffstat (limited to 'labbot')
-rw-r--r--labbot/config.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/labbot/config.py b/labbot/config.py
index 993d25a..7183786 100644
--- a/labbot/config.py
+++ b/labbot/config.py
@@ -34,18 +34,14 @@ class Config:
self.name = name
try:
- global_data = self.settings.get("GLOBAL", {})
-
- self.settings = json.load(
+ settings = json.load(
open(os.path.join(instance_path, f"{conf_name}.json")))
- # write the hardcoded config data ontop of the loaded data
- self.settings["GLOBAL"].update(global_data)
-
- try:
- self.settings["PROJECT"] = self.settings.pop("REPO")
- except KeyError:
- pass
+ # allow the config on disk to overwrite existing config keys
+ # but keep new ones around
+ self.settings["GLOBAL"].update(settings.get("GLOBAL", {}))
+ self.settings["GROUP"].update(settings.get("GROUP", {}))
+ self.settings["PROJECT"].update(settings.get("PROJECT", {}))
except (IOError, ValueError):
pass
@@ -89,12 +85,15 @@ class Config:
return decorator
def set_global_data(self, **kwargs):
+ kwargs.update(self.settings["GLOBAL"])
self.settings["GLOBAL"] = kwargs
def set_group_data(self, group_id, **kwargs):
+ kwargs.update(self.settings["GROUP"][group_id])
self.settings["GROUP"][group_id] = kwargs
def set_project_data(self, project_id, **kwargs):
+ kwargs.update(self.settings["PROJECT"][project_id])
self.settings["PROJECT"][project_id] = kwargs
def list_instances() -> List[str]: