Skip to content

Commit

Permalink
print image digest from wkg oci push
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts authored and thomastaylor312 committed Dec 10, 2024
1 parent fd2c893 commit afbd032
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/wkg/src/oci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit afbd032

Please sign in to comment.