Skip to content

Commit

Permalink
Silence warning emitted on config envvar
Browse files Browse the repository at this point in the history
  • Loading branch information
erwin-eiq committed Apr 13, 2022
1 parent aa03356 commit 5add91d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions opentaxii/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, optional_env_var=CONFIG_ENV_VAR, extra_configs=None):
if env_var_path:
configs.append(env_var_path)
# 1. config built from env vars
configs.append(self._get_env_config())
configs.append(self._get_env_config(optional_env_var=optional_env_var))

options = self._load_configs(*configs)
options = self._clean_options(options)
Expand All @@ -90,11 +90,13 @@ def __init__(self, optional_env_var=CONFIG_ENV_VAR, extra_configs=None):
super(ServerConfig, self).__init__(options)

@staticmethod
def _get_env_config(env=os.environ):
def _get_env_config(env=os.environ, optional_env_var=None):
result = _infinite_dict()
for key, value in env.items():
if not key.startswith(ENV_VAR_PREFIX):
continue
if key == optional_env_var:
continue
key = key[len(ENV_VAR_PREFIX):].lstrip("_").lower()
value = yaml.safe_load(value)

Expand Down

0 comments on commit 5add91d

Please sign in to comment.