diff --git a/rust/rpmostree-client/src/lib.rs b/rust/rpmostree-client/src/lib.rs index c3fded57..daf7250b 100644 --- a/rust/rpmostree-client/src/lib.rs +++ b/rust/rpmostree-client/src/lib.rs @@ -69,6 +69,15 @@ impl Status { } } +impl Deployment { + /// Find the base OSTree commit + pub fn get_base_commit(&self) -> &str { + self.base_checksum + .as_deref() + .unwrap_or(self.checksum.as_str()) + } +} + fn cli_cmd(c: &CliClient) -> Command { let mut cmd = Command::new("rpm-ostree"); cmd.env("RPMOSTREE_CLIENT_ID", c.agent_id.as_str()); diff --git a/rust/rpmostree-client/tests/parse.rs b/rust/rpmostree-client/tests/parse.rs index 56a67450..a4eb8283 100644 --- a/rust/rpmostree-client/tests/parse.rs +++ b/rust/rpmostree-client/tests/parse.rs @@ -9,5 +9,9 @@ fn parse_workstation() -> Result<()> { assert_eq!(state.deployments.len(), 2); let booted = state.require_booted().unwrap(); assert_eq!(booted.version.as_ref().unwrap().as_str(), "33.21"); + assert_eq!( + booted.get_base_commit(), + "229387d3c0bb8ad698228ca5702eca72aed8b298a7c800be1dc72bab160a9f7f" + ); Ok(()) }