Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sundog: strip "settings" prefix from populated settings #94

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion sources/api/sundog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ mod error {
source: serde_json::Error,
},

#[snafu(display("Error interpreting JSON value as API model: {}", source))]
InterpretModel { source: serde_json::Error },

#[snafu(display(
"Error deserializing command output as JSON from {}: '{}' ;: input: {}",
generator,
Expand Down Expand Up @@ -209,10 +212,17 @@ where
.context(error::GetPrefixSnafu { prefixes })?;
debug!("API response model: {}", response.to_string());

// Build a Settings struct from the response.
let settings = serde_json::from_value::<model::Model>(response)
.context(error::InterpretModelSnafu)?
.settings;

let settings_json = serde_json::to_value(settings).context(error::SerializeRequestSnafu)?;

// Serialize the response json into key/value pairs. This builds the dotted string
// representation of the setting
let settings_keypairs =
to_pairs_with_prefix("settings", &response).context(error::SerializeSettingsSnafu)?;
to_pairs_with_prefix("settings", &settings_json).context(error::SerializeSettingsSnafu)?;

// Put the setting into our hashset of populated keys
for (k, _) in settings_keypairs {
Expand Down