mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-25 23:09:22 +00:00
Accept environment variables in configuration
This commit is contained in:
parent
30f427b61c
commit
43c76fa120
@ -60,7 +60,7 @@ static mut CONF: Option<Config> = None;
|
||||
|
||||
impl Config {
|
||||
fn yaml_str(parsed: &Yaml, name: &str) -> String {
|
||||
match &parsed[name] {
|
||||
let val = match &parsed[name] {
|
||||
Yaml::Real(r) | Yaml::String(r) => r.to_string(),
|
||||
Yaml::Integer(i) => i.to_string(),
|
||||
Yaml::Boolean(true) => "true".to_string(),
|
||||
@ -71,7 +71,14 @@ impl Config {
|
||||
Yaml::BadValue => {
|
||||
panic!("{} is missing", name);
|
||||
}
|
||||
}.to_string()
|
||||
}.to_string();
|
||||
|
||||
// Check if we have to get an environment variable
|
||||
if val.starts_with("$") {
|
||||
std::env::var(&val[1..]).unwrap()
|
||||
} else {
|
||||
val
|
||||
}
|
||||
}
|
||||
|
||||
fn yaml_u64(parsed: &Yaml, name: &str) -> u64 {
|
||||
|
Loading…
Reference in New Issue
Block a user