From f22823a4c2f7cea733a54727544f58adabe527e6 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Wed, 14 Feb 2024 11:45:17 -0500 Subject: [PATCH] chore: Print out stderr from login attempts if login fails --- src/commands/build.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/commands/build.rs b/src/commands/build.rs index 3a93498..69a1608 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -311,7 +311,7 @@ impl BuildCommand { ); info!("Logging into the registry, {registry}"); - if !match ( + let login_output = match ( ops::check_command_exists("buildah"), ops::check_command_exists("podman"), ) { @@ -331,26 +331,26 @@ impl BuildCommand { .arg("-p") .arg(&password) .arg(®istry) - .output()? - .status - .success() - { - bail!("Failed to login for buildah!"); + .output()?; + + if !login_output.status.success() { + let err_out = String::from_utf8_lossy(&login_output.stderr); + bail!("Failed to login for buildah: {err_out}"); } trace!("cosign login -u {username} -p [MASKED] {registry}"); - if !Command::new("cosign") + let login_output = Command::new("cosign") .arg("login") .arg("-u") .arg(&username) .arg("-p") .arg(&password) .arg(®istry) - .output()? - .status - .success() - { - bail!("Failed to login for cosign!"); + .output()?; + + if !login_output.status.success() { + let err_output = String::from_utf8_lossy(&login_output.stderr); + bail!("Failed to login for cosign: {err_output}"); } info!("Login success at {registry}");