diff --git a/.github/actions/build-image/action.yml b/.github/actions/build-image/action.yml index 91cab7a..7ff8ab5 100644 --- a/.github/actions/build-image/action.yml +++ b/.github/actions/build-image/action.yml @@ -8,7 +8,7 @@ inputs: required: true runs: - using: 'composite' + using: "composite" steps: - name: Checkout uses: actions/checkout@v4 @@ -47,5 +47,6 @@ runs: platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Cargo.lock b/Cargo.lock index 244584c..cb2a131 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "cup" -version = "3.0.4" +version = "3.1.0" dependencies = [ "bollard", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 52f9263..c5ea765 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cup" -version = "3.0.4" +version = "3.1.0" edition = "2021" [dependencies] diff --git a/src/structs/image.rs b/src/structs/image.rs index 4c36309..fe31222 100644 --- a/src/structs/image.rs +++ b/src/structs/image.rs @@ -35,6 +35,7 @@ pub struct VersionInfo { pub struct Image { pub reference: String, pub parts: Parts, + pub url: Option, pub digest_info: Option, pub version_info: Option, pub error: Option, @@ -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 { diff --git a/src/structs/inspectdata.rs b/src/structs/inspectdata.rs index 81731de..52b1299 100644 --- a/src/structs/inspectdata.rs +++ b/src/structs/inspectdata.rs @@ -3,6 +3,7 @@ use bollard::secret::{ImageInspect, ImageSummary}; pub trait InspectData { fn tags(&self) -> Option<&Vec>; fn digests(&self) -> Option<&Vec>; + fn url(&self) -> Option; } impl InspectData for ImageInspect { @@ -13,6 +14,16 @@ impl InspectData for ImageInspect { fn digests(&self) -> Option<&Vec> { self.repo_digests.as_ref() } + + fn url(&self) -> Option { + 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> { Some(&self.repo_digests) } + + fn url(&self) -> Option { + self.labels.get("org.opencontainers.image.url").cloned() + } } diff --git a/src/structs/update.rs b/src/structs/update.rs index 21922a5..0c2f075 100644 --- a/src/structs/update.rs +++ b/src/structs/update.rs @@ -7,6 +7,7 @@ use super::{parts::Parts, status::Status}; pub struct Update { pub reference: String, pub parts: Parts, + pub url: Option, pub result: UpdateResult, pub time: u32, pub server: Option, diff --git a/web/src/components/Image.tsx b/web/src/components/Image.tsx index 53bb966..5693b37 100644 --- a/web/src/components/Image.tsx +++ b/web/src/components/Image.tsx @@ -40,7 +40,9 @@ export default function Image({ data }: { data: Image }) { : data.reference; const info = getInfo(data)!; let url: string | null = null; - if (clickable_registries.includes(data.parts.registry)) { + if (data.url) { + url = data.url; + } else if (clickable_registries.includes(data.parts.registry)) { switch (data.parts.registry) { case "registry-1.docker.io": url = `https://hub.docker.com/r/${data.parts.repository}`; @@ -82,7 +84,7 @@ export default function Image({ data }: { data: Image }) { >
- + {url ? ( <>