Skip to content

Commit 19a13fa

Browse files
authored
Merge pull request #94 from sam-berning/no-settings-prefix
sundog: strip "settings" prefix from populated settings
2 parents 3852578 + 3480896 commit 19a13fa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

sources/api/sundog/src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ mod error {
115115
source: serde_json::Error,
116116
},
117117

118+
#[snafu(display("Error interpreting JSON value as API model: {}", source))]
119+
InterpretModel { source: serde_json::Error },
120+
118121
#[snafu(display(
119122
"Error deserializing command output as JSON from {}: '{}' ;: input: {}",
120123
generator,
@@ -209,10 +212,17 @@ where
209212
.context(error::GetPrefixSnafu { prefixes })?;
210213
debug!("API response model: {}", response.to_string());
211214

215+
// Build a Settings struct from the response.
216+
let settings = serde_json::from_value::<model::Model>(response)
217+
.context(error::InterpretModelSnafu)?
218+
.settings;
219+
220+
let settings_json = serde_json::to_value(settings).context(error::SerializeRequestSnafu)?;
221+
212222
// Serialize the response json into key/value pairs. This builds the dotted string
213223
// representation of the setting
214224
let settings_keypairs =
215-
to_pairs_with_prefix("settings", &response).context(error::SerializeSettingsSnafu)?;
225+
to_pairs_with_prefix("settings", &settings_json).context(error::SerializeSettingsSnafu)?;
216226

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

0 commit comments

Comments
 (0)