Skip to content

Commit

Permalink
install: Warn on unknown keys
Browse files Browse the repository at this point in the history
Out of general principle, since we're adding new ones.

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Nov 17, 2023
1 parent 7d8a28b commit 5e64d34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ regex = "1.7.1"
rustix = { "version" = "0.38", features = ["thread", "fs", "system", "process"] }
schemars = { version = "0.8.6", features = ["chrono"] }
serde = { features = ["derive"], version = "1.0.125" }
serde_ignored = "0.1.9"
serde_json = "1.0.64"
serde_yaml = "0.9.17"
serde_with = ">= 1.9.4, < 2"
Expand Down
11 changes: 9 additions & 2 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,15 @@ pub(crate) mod config {
let mut config: Option<InstallConfiguration> = None;
for (_name, path) in fragments {
let buf = std::fs::read_to_string(&path)?;
let c: InstallConfigurationToplevel =
toml::from_str(&buf).with_context(|| format!("Parsing {path:?}"))?;
let mut unused = std::collections::HashSet::new();
let de = toml::Deserializer::new(&buf);
let c: InstallConfigurationToplevel = serde_ignored::deserialize(de, |path| {
unused.insert(path.to_string());
})
.with_context(|| format!("Parsing {path:?}"))?;
for key in unused {
eprintln!("warning: {path:?}: Unknown key {key}");
}
if let Some(config) = config.as_mut() {
if let Some(install) = c.install {
tracing::debug!("Merging install config: {install:?}");
Expand Down

0 comments on commit 5e64d34

Please sign in to comment.