Hardcoded fields are now correctly lowercase
This commit is contained in:
parent
fe0d53589f
commit
6e3036da7f
|
@ -105,7 +105,7 @@ class SecretLoader:
|
||||||
Hardcoded values are stored directly, and can be used to configure the
|
Hardcoded values are stored directly, and can be used to configure the
|
||||||
other subsystems.
|
other subsystems.
|
||||||
"""
|
"""
|
||||||
self.hardcoded: dict[str, str] = hardcoded
|
self.hardcoded: dict[str, str] = {k.lower(): v for k,v in hardcoded.items()}
|
||||||
self.pass_folder = None
|
self.pass_folder = None
|
||||||
self.vault_client = None
|
self.vault_client = None
|
||||||
self.env_key_prefix = None
|
self.env_key_prefix = None
|
||||||
|
@ -125,10 +125,11 @@ class SecretLoader:
|
||||||
|
|
||||||
# Setup secrets path
|
# Setup secrets path
|
||||||
self.secret_folder = Path(
|
self.secret_folder = Path(
|
||||||
self.hardcoded.get(ENV_KEY_SECRETS_DIRECTORY)
|
self.hardcoded.get(ENV_KEY_SECRETS_DIRECTORY.lower())
|
||||||
or self._load_or_none_env(ENV_KEY_SECRETS_DIRECTORY)
|
or self._load_or_none_env(ENV_KEY_SECRETS_DIRECTORY)
|
||||||
or DEFAULT_SECRETS_DIRECTORY,
|
or DEFAULT_SECRETS_DIRECTORY,
|
||||||
)
|
)
|
||||||
|
logger.info('Secrets folder is set to: %s', self.secret_folder)
|
||||||
|
|
||||||
# Setup pass
|
# Setup pass
|
||||||
self.pass_folder = self._load_or_none(ENV_KEY_PASS_FOLDER)
|
self.pass_folder = self._load_or_none(ENV_KEY_PASS_FOLDER)
|
||||||
|
@ -161,7 +162,7 @@ class SecretLoader:
|
||||||
return `None` if not found.
|
return `None` if not found.
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
self.hardcoded.get(secret_name)
|
self.hardcoded.get(secret_name.lower())
|
||||||
or self._load_or_none_path_or_file(secret_name)
|
or self._load_or_none_path_or_file(secret_name)
|
||||||
or self._load_or_none_local_password_store(secret_name)
|
or self._load_or_none_local_password_store(secret_name)
|
||||||
)
|
)
|
||||||
|
@ -188,7 +189,10 @@ class SecretLoader:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _load_or_none_env(self, secret_name) -> str | None:
|
def _load_or_none_env(self, secret_name) -> str | None:
|
||||||
return os.environ.get(f'{self.env_key_prefix}_{secret_name.upper()}')
|
if self.env_key_prefix is None:
|
||||||
|
return None
|
||||||
|
env_key = f'{self.env_key_prefix}_{secret_name.upper()}'
|
||||||
|
return os.environ.get(env_key)
|
||||||
|
|
||||||
def _load_or_none_local_password_store(self, secret_name: str) -> str | None:
|
def _load_or_none_local_password_store(self, secret_name: str) -> str | None:
|
||||||
"""Load secret from the `pass` password manager.
|
"""Load secret from the `pass` password manager.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user