Skip to content

Commit 95c3140

Browse files
committed
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] bootc-dev/ocidir-rs#28 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
1 parent 7f08c20 commit 95c3140

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

puzzlefs-lib/src/oci.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::str::FromStr;
2727
use std::io::Cursor;
2828

2929
pub mod media_types;
30-
const OCI_TAG_ANNOTATION: &str = "org.opencontainers.image.ref.name";
3130

3231
pub struct Image(pub OciDir);
3332

@@ -204,21 +203,10 @@ impl Image {
204203
Ok(file)
205204
}
206205

207-
// TODO: export this function from ocidr / find another way to avoid code duplication
208-
fn descriptor_is_tagged(d: &Descriptor, tag: &str) -> bool {
209-
d.annotations()
210-
.as_ref()
211-
.and_then(|annos| annos.get(OCI_TAG_ANNOTATION))
212-
.filter(|tagval| tagval.as_str() == tag)
213-
.is_some()
214-
}
215-
216206
pub fn get_image_manifest_fd(&self, tag: &str) -> Result<cap_std::fs::File> {
217-
let index = self.get_index()?;
218-
let image_manifest = index
219-
.manifests()
220-
.iter()
221-
.find(|desc| Self::descriptor_is_tagged(desc, tag))
207+
let image_manifest = self
208+
.0
209+
.find_manifest_descriptor_with_tag(tag)?
222210
.ok_or_else(|| {
223211
WireFormatError::MissingManifest(tag.to_string(), Backtrace::capture())
224212
})?;

0 commit comments

Comments
 (0)