feat: narrow error codes

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-01-28 21:36:26 +01:00
parent ede55b975b
commit 52c7f77751
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -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: {}",