From 52c7f7775156bd4f10d032735443ebd7c804f16b Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 28 Jan 2024 21:36:26 +0100 Subject: [PATCH] feat: narrow error codes Signed-off-by: kjuulh --- cuddle/src/cli/subcommands/kustomize.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cuddle/src/cli/subcommands/kustomize.rs b/cuddle/src/cli/subcommands/kustomize.rs index f0deb6f..bc1cbbd 100644 --- a/cuddle/src/cli/subcommands/kustomize.rs +++ b/cuddle/src/cli/subcommands/kustomize.rs @@ -1,5 +1,6 @@ use std::{io::Write, path::PathBuf}; +use anyhow::Context; use clap::{Arg, ArgMatches, Command}; use crate::cli::CuddleCli; @@ -51,7 +52,7 @@ impl KustomizeCommand { std::fs::create_dir_all(&self.destination)?; let cmd = cmd.arg("kustomize").arg(self.kustomize_folder); - let output = cmd.output()?; + let output = cmd.output().context("failed to run kubectl kustomize")?; if !output.status.success() { anyhow::bail!( @@ -66,13 +67,15 @@ impl KustomizeCommand { .arg(self.destination) .stdin(std::process::Stdio::piped()); - let mut child = cmd.spawn()?; + let mut child = cmd.spawn().context("failed to run kubectl-slice")?; if let Some(mut stdin) = child.stdin.take() { stdin.write_all(&output.stdout)?; } - let output = child.wait_with_output()?; + let output = child + .wait_with_output() + .context("failed to run kubectl-slice")?; if !output.status.success() { anyhow::bail!( "failed to run kustomize: {}",