Load multiple config files specified in the MAS_CONFIG env variable

This commit is contained in:
Quentin Gliech
2022-03-14 17:46:18 +01:00
parent 5e4037566f
commit eea9623e65

View File

@@ -72,7 +72,14 @@ impl Options {
pub fn load_config<'de, T: ConfigurationSection<'de>>(&self) -> anyhow::Result<T> {
let configs = if self.config.is_empty() {
vec![std::env::var("MAS_CONFIG").map_or_else(|_| "config.yaml".into(), PathBuf::from)]
// Read the MAS_CONFIG environment variable
std::env::var("MAS_CONFIG")
// Default to "config.yaml"
.unwrap_or_else(|_| "config.yaml".to_string())
// Split the file list on `:`
.split(':')
.map(PathBuf::from)
.collect()
} else {
self.config.clone()
};