rust/client: Add Deployment/get_base_commit() API

Zincati wants this.
This commit is contained in:
Colin Walters 2021-03-05 18:15:42 +00:00 committed by OpenShift Merge Robot
parent 14c17cfe52
commit 5b647af14a
2 changed files with 13 additions and 0 deletions

View File

@ -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());

View File

@ -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(())
}