aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ambre Bertucci <[email protected]>2023-06-20 10:25:01 +0200
committerGravatar GitHub <[email protected]>2023-06-20 09:25:01 +0100
commit1e589e673cbe2a3fcdddc7e977b247c4d4a6c89a (patch)
treea7d8600eeef4a6c372e8571da70f44e9bfb8b897
parentBump pydis-core from 9.5.1 to 9.6.0 (#50) (diff)
Allow changing the config file location with CONFIG_LOCATION (#56)
Currently, it is mandatory for you to put the config file in the same folder as the code. This raises issues in environments such as Kubernetes. This commit allows the user to use `CONFIG_LOCATION` to change the location of that file, while keeping the current behavior as default.
-rw-r--r--metricity/config.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/metricity/config.py b/metricity/config.py
index 99fd0c2..a77b252 100644
--- a/metricity/config.py
+++ b/metricity/config.py
@@ -33,10 +33,11 @@ def get_section(section: str) -> dict[str, Any]:
# Load user configuration
user_config = {}
+ user_config_location = Path(environ.get("CONFIG_LOCATION", "./config.toml"))
- if Path("config.toml").exists():
- with open("config.toml", "r") as default_config_file:
- user_config = toml.load(default_config_file)
+ if user_config_location.exists():
+ with open(user_config_location, "r") as user_config_file:
+ user_config = toml.load(user_config_file)
# Merge the configuration
merger = Merger(