diff --git a/Writerside/topics/Configuration.md b/Writerside/topics/Configuration.md index 0f77746..fad45ec 100644 --- a/Writerside/topics/Configuration.md +++ b/Writerside/topics/Configuration.md @@ -14,7 +14,8 @@ volumes: - ./config:/app/config ``` -Though you can change the location of the configuration file's directory by setting the `CONFIG_DIR` env variable to another path, +Though you can change the location of the configuration file's directory by setting the `CONFIG_DIR` env variable to +another path, e.g. `/etc/mediamanager/`. ## Configuration Sections @@ -43,7 +44,7 @@ token_secret = "your_super_secret_key_here" But you can also set it through an environment variable: ``` -AUTH__TOKEN_SECRET = "your_super_secret_key_here" +MEDIAMANAGER_AUTH__TOKEN_SECRET = "your_super_secret_key_here" ``` or another example with the OIDC client secret: @@ -58,10 +59,15 @@ client_secret = "your_client_secret_from_provider" env variable: ``` -AUTH__OPENID_CONNECT__CLIENT_SECRET = "your_client_secret_from_provider" +MEDIAMANAGER_AUTH__OPENID_CONNECT__CLIENT_SECRET = "your_client_secret_from_provider" ``` So for every config "level", you basically have to take the name of the value and prepend it with the section names in -uppercase with 2 underscores as delimiters. +uppercase with 2 underscores as delimiters and `MEDIAMANAGER_` as the prefix. + +Note that not every env variable starts with MEDIAMANAGER_, +this prefix only applies to env variables which replace/overwrite values in the config file. +Variables like the CONFIG_DIR env variable must not be prefixed. + diff --git a/media_manager/config.py b/media_manager/config.py index daa4f6e..ed066cb 100644 --- a/media_manager/config.py +++ b/media_manager/config.py @@ -48,7 +48,7 @@ class BasicConfig(BaseSettings): class AllEncompassingConfig(BaseSettings): model_config = SettingsConfigDict( - toml_file=config_path, case_sensitive=False, env_nested_delimiter="__" + toml_file=config_path, case_sensitive=False, env_nested_delimiter="__", env_prefix="MEDIAMANAGER_" ) """ This class is used to load all configurations from the environment variables.