supercontest.util.config
Utilities around config management.
Functions
Whether config should be read from the environment rather than from files. |
|
Reads the given keys out of the process environment. |
|
Takes a config file that does not have sections (headers) and returns the content anyway. |
- supercontest.util.config.config_from_env() bool
Whether config should be read from the environment rather than from files.
Set by the ECS service and the admin task definition. Absent everywhere else, so local dev and tests read the committed files.
- Returns:
True if the app should read config from the environment.
- supercontest.util.config.from_env(keys: list[str]) dict[str, str]
Reads the given keys out of the process environment.
ECS injects config as environment variables, sourced directly from Secrets Manager and SSM Parameter Store, so the app never calls either API itself. Local dev and tests keep reading the files instead – see the callers, which branch on
DEBUG/TESTING.- Parameters:
keys – The config keys to read.
- Raises:
KeyError – If any key is missing, naming all of them at once.
- Returns:
The key/val pairs from the environment.
- supercontest.util.config.get_sectionless_config(path: str, optional: bool = False) dict[Any, Any]
Takes a config file that does not have sections (headers) and returns the content anyway.
The reason this function is necessary: The database config files are passed both (1) as
env_filein docker compose and (2) as configparser inputs (ini style) insupercontest.settings.load_settings(). Env files cannot have section headers. Ini files must have section headers.So we keep the raw files sectionless. Docker reads them directly. The settings loader uses this to inject fake section headers.
Note also that because ConfigParser mimics ini, and ini is case-insensitive, we cast to strings here to maintain the casing in the raw files.
- Parameters:
path – Path to the config to be read.
optional – If True, a missing file yields an empty dict instead of raising. Used for the private overrides, which a fresh clone does not have and no longer needs.
- Returns:
The key/val pairs from the config.
- Raises:
FileNotFoundError – If the file is missing and
optionalis False.