diff options
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 3e7c5d4..a32211e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -29,9 +29,8 @@ use serde_json::Value as JsonValue; use tracing::{info, warn}; pub(crate) use ::config::arguments::{merged, with_options}; -#[cfg(feature = "federation")] pub(crate) use ::config::layer::read; -pub(crate) use ::config::layer::{Entry, Layer, Origin, Provenance}; +pub(crate) use ::config::layer::{Layer, Origin, Provenance}; pub(crate) use ::config::option::{Kind, OptionSpec, Schema, option}; /// What the node's configuration is read by: its options, those that can't be combined, @@ -49,7 +48,7 @@ pub(crate) const PARTY: Schema = Schema::of(PARTY_OPTIONS); /// As the crate's, by the node's options: what the tests call. #[cfg(test)] use ::config::{ - layer::{Overlay, unset_entry}, + layer::{Entry, Overlay, unset_entry}, option::from_text, }; @@ -1540,18 +1539,6 @@ const CONFLICTS: &[(&[&str], &[&str])] = &[( ], )]; -/// The first option whose value alone doesn't fit (serde doesn't name it). -fn culprit(merged: &Layer) -> Option<(&String, &Entry)> { - merged.iter().find(|(name, entry)| { - if entry.value.is_null() { - return false; - } - let mut alone = serde_json::Map::new(); - alone.insert((*name).clone(), entry.value.clone()); - serde_json::from_value::<Settings>(JsonValue::Object(alone)).is_err() - }) -} - // --- command line -------------------------------------------------------------- const PRINT_CONFIG: &str = "print-config"; @@ -1825,22 +1812,9 @@ fn resolve(merged: Layer, files: Vec<PathBuf>) -> Result<Loaded> { entry.origin ); } - // Unset options take their defaults. - let object: serde_json::Map<String, JsonValue> = merged - .iter() - .filter(|(_, entry)| !entry.value.is_null()) - .map(|(name, entry)| (name.clone(), entry.value.clone())) - .collect(); + // Unset options take their defaults; an option whose value fits not is named. let mut settings: Settings = - serde_json::from_value(JsonValue::Object(object)).map_err(|error| { - match culprit(&merged) { - Some((name, entry)) => anyhow!( - "invalid configuration: option {name} (set in {}): {error}", - entry.origin - ), - None => anyhow!("invalid configuration: {error}"), - } - })?; + read(&merged).map_err(|error| anyhow!("invalid configuration: {error}"))?; settings.alias = settings.alias.map(|alias| alias.trim().to_owned()); settings.transports = settings.ordered_transports(); settings.check().context("invalid configuration")?; |
