Simplify Figment init, toml config file folding.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-01-31 09:14:22 +00:00
parent 2fb032fabb
commit 1fc69efffe

View File

@@ -13,7 +13,7 @@ use either::{
Either, Either,
Either::{Left, Right}, Either::{Left, Right},
}; };
use figment::providers::{Env, Format, Toml}; use figment::providers::{Data, Env, Format, Toml};
pub use figment::{Figment, value::Value as FigmentValue}; pub use figment::{Figment, value::Value as FigmentValue};
use itertools::Itertools; use itertools::Itertools;
use regex::RegexSet; use regex::RegexSet;
@@ -2951,7 +2951,8 @@ impl Config {
let config = toml_files let config = toml_files
.iter() .iter()
.map(Toml::file) .map(Toml::file)
.fold(Figment::new(), |config, file| config.merge(file.nested())) .map(Data::nested)
.fold(Figment::new(), Figment::merge)
.merge(Env::prefixed("CONDUIT_").global().split("__")) .merge(Env::prefixed("CONDUIT_").global().split("__"))
.merge(Env::prefixed("CONDUWUIT_").global().split("__")) .merge(Env::prefixed("CONDUWUIT_").global().split("__"))
.merge(Env::prefixed("TUWUNEL_").global().split("__")); .merge(Env::prefixed("TUWUNEL_").global().split("__"));