From f9747816dba8200475584f17e5324f000a00ad11 Mon Sep 17 00:00:00 2001 From: Alma <113595328+almarzn@users.noreply.github.com> Date: Sun, 10 Aug 2025 15:42:56 +0200 Subject: [PATCH 1/2] add a prefix for environment variables --- media_manager/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 35a4b4a14c9bbeabb9f2359ab285e885d22051a1 Mon Sep 17 00:00:00 2001 From: maxDorninger <97409287+maxDorninger@users.noreply.github.com> Date: Mon, 11 Aug 2025 22:22:14 +0200 Subject: [PATCH 2/2] add MEDIAMANAGER prefix to documentation --- Writerside/topics/Configuration.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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. +