Skip to content

Commit 36ba8b4

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 94b701f commit 36ba8b4

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-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.210", features = ["derive"] }
1617
serde_derive = "1.0.118"
1718
serde_json = "1.0.133"

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

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

44
use anyhow::Context;
5-
use serde_derive::Deserialize;
5+
use oci_spec;
6+
use serde::Deserialize;
67
use std::collections::HashMap;
78
use std::process::Command;
89

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

102119
impl CliClient {

0 commit comments

Comments
 (0)