From 90e97433e064f512e5a5fbbe0234569696433f72 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 24 May 2022 17:37:31 +0200 Subject: [PATCH] Added logic to load all environment variables by prefix --- src/cpl_core/configuration/configuration.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index 3de4fbc2..2b882fb0 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -200,10 +200,11 @@ class Configuration(ConfigurationABC): self._additional_arguments.append(arg_str) def add_environment_variables(self, prefix: str): - for variable in ConfigurationVariableNameEnum.to_list(): - var_name = f'{prefix}{variable}' - if var_name in [key.upper() for key in os.environ.keys()]: - self._set_variable(variable, os.environ[var_name]) + for env_var in os.environ.keys(): + if not env_var.startswith(prefix): + continue + + self._set_variable(env_var.replace(prefix, ''), os.environ[env_var]) def add_console_argument(self, argument: ArgumentABC): self._argument_types.append(argument)