diff --git a/lib/src/container/store.rs b/lib/src/container/store.rs index 23960b5d..901067b0 100644 --- a/lib/src/container/store.rs +++ b/lib/src/container/store.rs @@ -140,6 +140,13 @@ impl LayeredImageState { self.base_commit.as_str() } } + + /// Retrieve the container image version. + pub fn version(&self) -> Option<&str> { + self.configuration + .as_ref() + .and_then(super::version_for_config) + } } /// Locally cached metadata for an update to an existing image. @@ -153,6 +160,13 @@ pub struct CachedImageUpdate { pub manifest_digest: String, } +impl CachedImageUpdate { + /// Retrieve the container image version. + pub fn version(&self) -> Option<&str> { + super::version_for_config(&self.config) + } +} + /// Context for importing a container image. #[derive(Debug)] pub struct ImageImporter { diff --git a/lib/tests/it/main.rs b/lib/tests/it/main.rs index 483e955c..5a10b816 100644 --- a/lib/tests/it/main.rs +++ b/lib/tests/it/main.rs @@ -780,13 +780,15 @@ r usr/bin/bash bash-v0 { let cached = store::query_image_ref(fixture.destrepo(), &imgref.imgref) .unwrap() - .unwrap() - .cached_update .unwrap(); + assert_eq!(cached.version(), Some("42.0")); + + let cached_update = cached.cached_update.unwrap(); assert_eq!( - cached.manifest_digest.as_str(), + cached_update.manifest_digest.as_str(), prep.manifest_digest.as_str() ); + assert_eq!(cached_update.version(), Some("42.0")); } let to_fetch = prep.layers_to_fetch().collect::>>()?; assert_eq!(to_fetch.len(), 2);