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:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user