Skip to content

Commit b0fb8b0

Browse files
committed
rust/rpmostree-client: parse OCI deployment manifest
When the deployment is an OCI image, the base_commit_meta field contains nested escaped JSON. Add a method to get the base oci manifest deserialized into an ImageManifest from the oci-spec rust crate. Fixes #5196
1 parent 0b11110 commit b0fb8b0

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

Diff for: rust/rpmostree-client/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ publish = false
1212

1313
[dependencies]
1414
anyhow = "1.0.94"
15+
oci-spec = "0.7.1"
1516
serde = { version = "1.0.217", features = ["derive"] }
1617
serde_derive = "1.0.118"
1718
serde_json = "1.0.135"

Diff for: rust/rpmostree-client/src/lib.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
use anyhow::Context;
5-
use serde_derive::Deserialize;
5+
use serde::Deserialize;
66
use std::collections::HashMap;
77
use std::process::Command;
88

@@ -97,6 +97,22 @@ impl Deployment {
9797
Err(format!("No {} metadata key", k).into())
9898
}
9999
}
100+
101+
pub fn get_base_manifest(&self) -> Result<Option<oci_spec::image::ImageManifest>> {
102+
if self.container_image_reference.is_none() {
103+
return Ok(None);
104+
}
105+
106+
let manifest = self.base_commit_meta.get("ostree.manifest");
107+
if let Some(inner) = manifest {
108+
let deser = String::deserialize(inner)?;
109+
let manifest: oci_spec::image::ImageManifest = serde_json::from_str(deser.as_str())?;
110+
111+
return Ok(Some(manifest));
112+
};
113+
114+
Ok(None)
115+
}
100116
}
101117

102118
impl CliClient {

0 commit comments

Comments
 (0)