Skip to content

Commit 18c6368

Browse files
feat: improve wrong version error message (#1733)
1 parent 916b4c6 commit 18c6368

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

agent-control/src/cli/install.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{
1717
with_start_time::StartTime,
1818
},
1919
k8s::{
20+
Error as K8sError,
2021
labels::{AGENT_CONTROL_VERSION_SET_FROM, LOCAL_VAL, REMOTE_VAL},
2122
utils::{get_name, get_type_meta},
2223
},
@@ -121,10 +122,16 @@ pub fn apply_resources(
121122
let k8s_client = try_new_k8s_client()?;
122123
let maybe_helm_release = k8s_client
123124
.get_dynamic_object(&helmrelease_v2_type_meta(), release_name, namespace)
124-
.map_err(|err| {
125-
CliError::ApplyResource(format!(
126-
"could not get helmRelease with name {release_name}: {err}",
127-
))
125+
.map_err(|err| match err {
126+
// Specifying an invalid version of `agent-control-cd` throws an error showing that something is wrong with the api.
127+
// It can be hard to understand without prior knowledge, thus we simplify the error message for that specific variant.
128+
K8sError::MissingAPIResource(_) => CliError::ApplyResource(format!(
129+
"could not get HelmRelease with name {release_name} and version {}",
130+
install_data.chart_version
131+
)),
132+
_ => CliError::ApplyResource(format!(
133+
"could not get HelmRelease with name {release_name}: {err}",
134+
)),
128135
})?;
129136

130137
let skip_installation_check = install_data.skip_installation_check;

0 commit comments

Comments
 (0)