fix: config empty values unset, drop adapter from_vars
This commit is contained in:
@@ -59,7 +59,8 @@ const LEGACY_ENV: &[(&str, &str)] = &[
|
||||
];
|
||||
|
||||
/// Reads the legacy variables as plain strings; typing is left to the config
|
||||
/// structs so that e.g. `JWT_SECRET=12345` stays a string.
|
||||
/// structs so that e.g. `JWT_SECRET=12345` stays a string. Empty or
|
||||
/// whitespace-only values are skipped as unset.
|
||||
struct LegacyEnv;
|
||||
|
||||
impl Provider for LegacyEnv {
|
||||
@@ -76,6 +77,11 @@ impl Provider for LegacyEnv {
|
||||
let value = raw
|
||||
.into_string()
|
||||
.map_err(|_| figment::Error::from(format!("{variable} is not valid unicode")))?;
|
||||
// An empty value (`PORT=` in a .env template) means "not set": the
|
||||
// default applies, or the optional field stays `None`.
|
||||
if value.trim().is_empty() {
|
||||
continue;
|
||||
}
|
||||
let (section, field) = key.split_once('.').expect("legacy keys are section.field");
|
||||
let entry = sections
|
||||
.entry(section.to_owned())
|
||||
|
||||
Reference in New Issue
Block a user