feat: narrow error codes
All checks were successful
continuous-integration/drone/push Build is passing

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 std::{io::Write, path::PathBuf};
use anyhow::Context;
use clap::{Arg, ArgMatches, Command}; use clap::{Arg, ArgMatches, Command};
use crate::cli::CuddleCli; use crate::cli::CuddleCli;
@ -51,7 +52,7 @@ impl KustomizeCommand {
std::fs::create_dir_all(&self.destination)?; std::fs::create_dir_all(&self.destination)?;
let cmd = cmd.arg("kustomize").arg(self.kustomize_folder); 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() { if !output.status.success() {
anyhow::bail!( anyhow::bail!(
@ -66,13 +67,15 @@ impl KustomizeCommand {
.arg(self.destination) .arg(self.destination)
.stdin(std::process::Stdio::piped()); .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() { if let Some(mut stdin) = child.stdin.take() {
stdin.write_all(&output.stdout)?; 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() { if !output.status.success() {
anyhow::bail!( anyhow::bail!(
"failed to run kustomize: {}", "failed to run kustomize: {}",