Skip to content

Commit afbd032

Browse files
yoshuawuytsthomastaylor312
authored andcommitted
print image digest from wkg oci push
1 parent fd2c893 commit afbd032

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crates/wkg/src/oci.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::Context;
44
use clap::{Args, Subcommand};
55
use docker_credential::DockerCredential;
66
use oci_client::{
7-
client::{ClientConfig, ClientProtocol},
7+
client::{ClientConfig, ClientProtocol, PushResponse},
88
secrets::RegistryAuth,
99
Reference,
1010
};
@@ -156,15 +156,25 @@ impl PushArgs {
156156
};
157157

158158
let auth = self.auth.into_auth(&self.reference)?;
159-
client
159+
let res = client
160160
.push(&self.reference, &auth, layer, conf, annotations)
161161
.await
162162
.context("Unable to push image")?;
163-
println!("Pushed {}", self.reference);
163+
println!("pushed: {}", self.reference);
164+
165+
let PushResponse { manifest_url, .. } = res;
166+
println!("digest: {}", digest_from_manifest_url(&manifest_url));
167+
164168
Ok(())
165169
}
166170
}
167171

172+
fn digest_from_manifest_url(url: &str) -> &str {
173+
url.split('/')
174+
.last()
175+
.expect("url did not contain manifest sha256")
176+
}
177+
168178
impl PullArgs {
169179
pub async fn run(self) -> anyhow::Result<()> {
170180
let client = get_client(self.common);

0 commit comments

Comments
 (0)