mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-10-23 04:28:09 +03:00
Accept y/n, True/False, 1/0 as booleans in environment vars
This commit is contained in:
2 files changed
+19
-4
No files matched your search
+11
@@ -309,6 +309,17 @@ where
|
||||
try_parse_string(env::var(key))
|
||||
}
|
||||
|
||||
const TRUE_VALUES: &[&str] = &["true", "t", "yes", "y", "1"];
|
||||
const FALSE_VALUES: &[&str] = &["false", "f", "no", "n", "0"];
|
||||
|
||||
pub fn get_env_bool(key: &str) -> Option<bool> {
|
||||
match env::var(key) {
|
||||
Ok(val) if TRUE_VALUES.contains(&val.to_lowercase().as_ref()) => Some(true),
|
||||
Ok(val) if FALSE_VALUES.contains(&val.to_lowercase().as_ref()) => Some(false),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Date util methods
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user