fix(#298): Don't throw error if no Helm repository found (#305)

This commit is contained in:
Baptiste
2023-01-09 08:57:32 +01:00
committed by GitHub
parent cb4871321d
commit 07e0fc5e5c
3 changed files with 30 additions and 31 deletions

34
Cargo.lock generated
View File

@@ -1061,24 +1061,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.7.14"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys",
]
[[package]]
@@ -1120,15 +1110,6 @@ dependencies = [
"zvariant_derive",
]
[[package]]
name = "ntapi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
dependencies = [
"winapi",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
@@ -2003,19 +1984,18 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.8.5"
version = "1.18.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc46ca74dd45faeaaf96a8fbe2406f425829705ee62100ccaa9b34a2145cff8"
checksum = "8bfb875c82dc0a4f1f37a30e720dee181a2b3a06a428b0fc6873ea38d6407850"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"once_cell",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"winapi",
]

View File

@@ -39,7 +39,7 @@ strum = { version = "~0.24", features = ["derive"] }
thiserror = "~1.0"
tempfile = "~3.2"
cfg-if = "~1.0"
tokio = { version = "~1.8", features = ["process", "rt-multi-thread"] }
tokio = { version = "~1.18", features = ["process", "rt-multi-thread"] }
futures = "~0.3"
regex = "~1.5"
semver = "~1.0"

View File

@@ -10,7 +10,7 @@ use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use directories::BaseDirs;
use tempfile::tempfile_in;
use tracing::debug;
use tracing::{debug, error};
use crate::command::{CommandExt, Utf8Output};
use crate::execution_context::ExecutionContext;
@@ -18,7 +18,7 @@ use crate::executor::{ExecutorOutput, RunType};
use crate::terminal::{print_separator, shell};
use crate::utils::{self, require_option, PathExt};
use crate::{
error::{SkipStep, TopgradeError},
error::{SkipStep, StepFailed, TopgradeError},
terminal::print_warning,
};
@@ -591,5 +591,24 @@ pub fn run_helm_repo_update(run_type: RunType) -> Result<()> {
let helm = utils::require("helm")?;
print_separator("Helm");
run_type.execute(helm).arg("repo").arg("update").status_checked()
let no_repo = "no repositories found";
let mut success = true;
let mut exec = run_type.execute(helm);
if let Err(e) = exec.arg("repo").arg("update").status_checked() {
error!("Updating repositories failed: {}", e);
success = match exec.output_checked_utf8() {
Ok(s) => s.stdout.contains(no_repo) || s.stderr.contains(no_repo),
Err(e) => match e.downcast_ref::<TopgradeError>() {
Some(TopgradeError::ProcessFailedWithOutput(_, _, stderr)) => stderr.contains(no_repo),
_ => false,
},
};
}
if success {
Ok(())
} else {
Err(eyre!(StepFailed))
}
}