m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-17 09:33:38 -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

@@ -35,6 +35,7 @@ pub struct VersionInfo {
pub struct Image {
pub reference: String,
pub parts: Parts,
pub url: Option<String>,
pub digest_info: Option<DigestInfo>,
pub version_info: Option<VersionInfo>,
pub error: Option<String>,
@@ -61,6 +62,7 @@ impl Image {
repository,
tag,
},
url: image.url(),
digest_info: Some(DigestInfo {
local_digests,
remote_digest: None,
@@ -141,6 +143,7 @@ impl Image {
Update {
reference: self.reference.clone(),
parts: self.parts.clone(),
url: self.url.clone(),
result: UpdateResult {
has_update: has_update.to_option_bool(),
info: match has_update {

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()
}
}

View File

@@ -7,6 +7,7 @@ use super::{parts::Parts, status::Status};
pub struct Update {
pub reference: String,
pub parts: Parts,
pub url: Option<String>,
pub result: UpdateResult,
pub time: u32,
pub server: Option<String>,