Skip to content
Snippets Groups Projects
Commit df4fa9e0 authored by Éloïs's avatar Éloïs
Browse files

fix(conf): load module conf from env var must use uppercased module name

parent 3e703a23
No related branches found
No related tags found
No related merge requests found
Pipeline #12179 passed
......@@ -788,6 +788,7 @@ dependencies = [
"dubp",
"envy",
"futures-util",
"log",
"serde",
"serde_json",
]
......
......@@ -10,5 +10,6 @@ anyhow = "1.0.34"
dubp = { version = "0.53.1", features = ["duniter"] }
envy = "0.4.2"
futures-util = "0.3"
log = "0.4"
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.53"
......@@ -57,9 +57,14 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
profile_path_opt: &Option<PathBuf>,
) -> anyhow::Result<C> {
if let Some(ref profile_path) = profile_path_opt {
if let Ok(conf) = envy::prefixed(format!("DUNITER_{}_", module_name)).from_env::<C>() {
Ok(conf)
} else {
match envy::prefixed(format!("DUNITER_{}_", module_name.to_uppercase())).from_env::<C>() {
Ok(conf) => Ok(conf),
Err(e) => {
log::debug!(
"load_module_conf(module_name: {}): envy error={}",
module_name,
e
);
let conf_file_path = find_module_conf_file_path(module_name, profile_path)?;
if conf_file_path.exists() {
let mut file = std::fs::File::open(conf_file_path)?;
......@@ -73,6 +78,7 @@ pub fn load_module_conf<C: Default + DeserializeOwned>(
Ok(C::default())
}
}
}
} else {
Ok(C::default())
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment