diff --git a/src/check.rs b/src/check.rs index 7eef206..3f31751 100644 --- a/src/check.rs +++ b/src/check.rs @@ -125,8 +125,10 @@ pub async fn get_updates( // Complete in_use field images.iter_mut().for_each(|image| { - if in_use_images.contains(&image.reference) { - image.in_use = true + if let Some(id) = &image.id { + if in_use_images.contains(id) { + image.in_use = true + } } }); diff --git a/src/docker.rs b/src/docker.rs index 633f2e6..8d8480d 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -120,14 +120,8 @@ pub async fn get_in_use_images(ctx: &Context) -> Vec { containers .iter() - .filter_map(|container| match &container.image { - Some(image) => Some({ - if image.contains(":") { - image.clone() - } else { - format!("{image}:latest") - } - }), + .filter_map(|container| match &container.image_id { + Some(image_id) => Some(image_id.clone()), None => None, }) .collect() diff --git a/src/structs/image.rs b/src/structs/image.rs index a180bfa..5d07e51 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -33,6 +33,7 @@ pub struct VersionInfo { #[derive(Clone, PartialEq, Default)] #[cfg_attr(test, derive(Debug))] pub struct Image { + pub id: Option, pub reference: String, pub parts: Parts, pub url: Option, @@ -71,6 +72,7 @@ impl Image { ) .collect(); Some(Self { + id: image.image_id(), reference, parts: Parts { registry, diff --git a/src/structs/inspectdata.rs b/src/structs/inspectdata.rs index c4640e1..04d0e57 100644 --- a/src/structs/inspectdata.rs +++ b/src/structs/inspectdata.rs @@ -4,6 +4,7 @@ pub trait InspectData { fn tags(&self) -> Option>; fn digests(&self) -> Option>; fn url(&self) -> Option; + fn image_id(&self) -> Option; } impl InspectData for ImageInspect { @@ -24,6 +25,10 @@ impl InspectData for ImageInspect { None => None, } } + + fn image_id(&self) -> Option { + self.id.clone() + } } impl InspectData for ImageSummary { @@ -38,6 +43,10 @@ impl InspectData for ImageSummary { fn url(&self) -> Option { self.labels.get("org.opencontainers.image.url").cloned() } + + fn image_id(&self) -> Option { + Some(self.id.clone()) + } } impl InspectData for &String { @@ -59,4 +68,8 @@ impl InspectData for &String { fn url(&self) -> Option { None } + + fn image_id(&self) -> Option { + None + } }