From 2917623f599cd27ccef73809e3f66d777d60c653 Mon Sep 17 00:00:00 2001 From: Yosh Date: Mon, 9 Dec 2024 20:11:07 +0100 Subject: [PATCH] print image digest from `wkg oci push` --- crates/wkg/src/oci.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/wkg/src/oci.rs b/crates/wkg/src/oci.rs index ffcb2fd..a851339 100644 --- a/crates/wkg/src/oci.rs +++ b/crates/wkg/src/oci.rs @@ -4,7 +4,7 @@ use anyhow::Context; use clap::{Args, Subcommand}; use docker_credential::DockerCredential; use oci_client::{ - client::{ClientConfig, ClientProtocol}, + client::{ClientConfig, ClientProtocol, PushResponse}, secrets::RegistryAuth, Reference, }; @@ -156,15 +156,25 @@ impl PushArgs { }; let auth = self.auth.into_auth(&self.reference)?; - client + let res = client .push(&self.reference, &auth, layer, conf, annotations) .await .context("Unable to push image")?; - println!("Pushed {}", self.reference); + println!("pushed: {}", self.reference); + + let PushResponse { manifest_url, .. } = res; + println!("digest: {}", digest_from_manifest_url(&manifest_url)); + Ok(()) } } +fn digest_from_manifest_url(url: &str) -> &str { + url.split('/') + .last() + .expect("url did not contain manifest sha256") +} + impl PullArgs { pub async fn run(self) -> anyhow::Result<()> { let client = get_client(self.common);