feat: narrow error codes
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
ede55b975b
commit
52c7f77751
@ -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: {}",
|
||||||
|
Loading…
Reference in New Issue
Block a user