From 3354ca9d302504736c88fecc9f199a9063308397 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 4 Mar 2021 22:17:39 +0000 Subject: [PATCH] rust/client: Extend with more metadata for zincati Add more metadata that zincati needs, like `base-commit-meta` which includes the `fedora-coreos.stream` key and the cosa basearch, etc. Also `Derive(Debug)` since it's used in a cache struct that also derives debug, and that's a friendly thing to do in general. --- rust/rpmostree-client/src/lib.rs | 8 ++++++-- rust/rpmostree-client/tests/parse.rs | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rust/rpmostree-client/src/lib.rs b/rust/rpmostree-client/src/lib.rs index f73e968f..ef1bfca6 100644 --- a/rust/rpmostree-client/src/lib.rs +++ b/rust/rpmostree-client/src/lib.rs @@ -3,6 +3,7 @@ use anyhow::Context; use serde_derive::Deserialize; +use std::collections::HashMap; use std::process::Command; /// Our generic catchall fatal error, expected to be converted @@ -12,24 +13,27 @@ type Result = std::result::Result, } /// A single deployment, i.e. a bootable ostree commit -#[derive(Deserialize)] +#[derive(Debug, Deserialize)] #[serde(rename_all = "kebab-case")] pub struct Deployment { pub unlocked: Option, pub osname: String, pub pinned: bool, pub checksum: String, + pub base_checksum: Option, + pub base_commit_meta: HashMap, pub staged: Option, pub booted: bool, pub serial: u32, pub origin: String, + pub version: Option, } /// Gather a snapshot of the system status. diff --git a/rust/rpmostree-client/tests/parse.rs b/rust/rpmostree-client/tests/parse.rs index e4aa76e2..524e1a5a 100644 --- a/rust/rpmostree-client/tests/parse.rs +++ b/rust/rpmostree-client/tests/parse.rs @@ -5,7 +5,9 @@ use rpmostree_client; #[test] fn parse_workstation() -> Result<()> { let data = include_str!("fixtures/workstation-status.json"); - let state: rpmostree_client::Status = serde_json::from_str(data)?; + let state: &rpmostree_client::Status = &serde_json::from_str(data)?; assert_eq!(state.deployments.len(), 2); + let booted = &state.deployments[0]; + assert_eq!(booted.version.as_ref().unwrap().as_str(), "33.21"); Ok(()) }