From 8e0e46c1ae74bdcd117509c02a8e01642d9e0505 Mon Sep 17 00:00:00 2001 From: Mark Murnane Date: Mon, 15 Apr 2024 00:36:43 -0400 Subject: [PATCH] Giving environment variables priority over files --- sideboard/config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sideboard/config.py b/sideboard/config.py index 1b84896..98eab09 100755 --- a/sideboard/config.py +++ b/sideboard/config.py @@ -156,11 +156,6 @@ def parse_config(requesting_file_path, is_plugin=True): root_conf = ['root = "{}"\n'.format(root_dir), 'module_root = "{}"\n'.format(module_dir)] temp_config = configobj.ConfigObj(root_conf, interpolation=False, encoding='utf-8') - environment_config = load_section_from_environment(plugin_name, spec) - print(f"Environment config for {plugin_name}") - print(json.dumps(environment_config, indent=2, sort_keys=True)) - temp_config.merge(configobj.ConfigObj(environment_config, encoding='utf-8', interpolation=False)) - for config_path in get_config_files(requesting_file_path, is_plugin): # this gracefully handles nonexistent files file_config = configobj.ConfigObj(str(config_path), encoding='utf-8', interpolation=False) @@ -168,6 +163,11 @@ def parse_config(requesting_file_path, is_plugin=True): print(json.dumps(file_config, indent=2, sort_keys=True)) temp_config.merge(file_config) + environment_config = load_section_from_environment(plugin_name, spec) + print(f"Environment config for {plugin_name}") + print(json.dumps(environment_config, indent=2, sort_keys=True)) + temp_config.merge(configobj.ConfigObj(environment_config, encoding='utf-8', interpolation=False)) + # combining the merge files to one file helps configspecs with interpolation with NamedTemporaryFile(delete=False) as config_outfile: temp_config.write(config_outfile)