ci: docker_tag=ext - Fix config file reading logic to properly read from file when env vars are missing

This commit is contained in:
4NK Dev 2025-09-21 21:04:08 +00:00
parent 0a02c708fc
commit 0180d32472

View File

@ -46,8 +46,7 @@ impl Config {
}
}
// Fallback to file if environment variables are not set
if file_content.is_empty() {
// Read from file to complete missing environment variables
if let Ok(file) = File::open(filename) {
let reader = io::BufReader::new(file);
@ -61,14 +60,19 @@ impl Config {
// Split the line into key and value
if let Some((k, v)) = l.split_once('=') {
file_content.insert(k.to_owned(), v.trim_matches('\"').to_owned());
let key = k.trim().to_owned();
let value = v.trim().trim_matches('\"').to_owned();
// Only insert if not already set by environment variables
if !file_content.contains_key(&key) {
file_content.insert(key, value);
}
}
}
} else {
}
} else if file_content.is_empty() {
return Err(anyhow::Error::msg("Failed to find conf file and no environment variables set"));
}
}
// Now set the Config
let config = Config {