From 0e4e62760b731f5ef40c0a00d7fad784d1b86e7f Mon Sep 17 00:00:00 2001 From: Ariel Miculas-Trif Date: Thu, 3 Oct 2024 13:34:34 +0300 Subject: [PATCH] Use find_manifest_descriptor_with_tag from ocidir-rs Now that [1] was merged, we can use find_manifest_descriptor_with_tag and remove copy-pasted code from ocidir-rs. [1] https://github.com/containers/ocidir-rs/pull/28 Signed-off-by: Ariel Miculas-Trif --- puzzlefs-lib/src/oci.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/puzzlefs-lib/src/oci.rs b/puzzlefs-lib/src/oci.rs index 6c82c3a..9ddc55f 100644 --- a/puzzlefs-lib/src/oci.rs +++ b/puzzlefs-lib/src/oci.rs @@ -27,7 +27,6 @@ use std::str::FromStr; use std::io::Cursor; pub mod media_types; -const OCI_TAG_ANNOTATION: &str = "org.opencontainers.image.ref.name"; pub struct Image(pub OciDir); @@ -204,21 +203,10 @@ impl Image { Ok(file) } - // TODO: export this function from ocidr / find another way to avoid code duplication - fn descriptor_is_tagged(d: &Descriptor, tag: &str) -> bool { - d.annotations() - .as_ref() - .and_then(|annos| annos.get(OCI_TAG_ANNOTATION)) - .filter(|tagval| tagval.as_str() == tag) - .is_some() - } - pub fn get_image_manifest_fd(&self, tag: &str) -> Result { - let index = self.get_index()?; - let image_manifest = index - .manifests() - .iter() - .find(|desc| Self::descriptor_is_tagged(desc, tag)) + let image_manifest = self + .0 + .find_manifest_descriptor_with_tag(tag)? .ok_or_else(|| { WireFormatError::MissingManifest(tag.to_string(), Backtrace::capture()) })?;