m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-18 09:53:43 -05:00

feat: detect image url from label

This commit is contained in:
Sergio
2025-03-11 17:06:00 +02:00
parent a5a1f12899
commit a599d4e084
8 changed files with 28 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ use bollard::secret::{ImageInspect, ImageSummary};
pub trait InspectData {
fn tags(&self) -> Option<&Vec<String>>;
fn digests(&self) -> Option<&Vec<String>>;
fn url(&self) -> Option<String>;
}
impl InspectData for ImageInspect {
@@ -13,6 +14,16 @@ impl InspectData for ImageInspect {
fn digests(&self) -> Option<&Vec<String>> {
self.repo_digests.as_ref()
}
fn url(&self) -> Option<String> {
match &self.config {
Some(config) => match &config.labels {
Some(labels) => labels.get("org.opencontainers.image.url").cloned(),
None => None,
},
None => None,
}
}
}
impl InspectData for ImageSummary {
@@ -23,4 +34,8 @@ impl InspectData for ImageSummary {
fn digests(&self) -> Option<&Vec<String>> {
Some(&self.repo_digests)
}
fn url(&self) -> Option<String> {
self.labels.get("org.opencontainers.image.url").cloned()
}
}