fix: made -version version, used ok_or to return error if k8s_state is not ready
This commit is contained in:
parent
c00eadca5d
commit
7576c4a74c
@ -38,7 +38,7 @@ impl K8sAnywhereTopology {
|
||||
|
||||
fn is_helm_available(&self) -> Result<(), String> {
|
||||
let version_result = Command::new("helm")
|
||||
.arg("-version")
|
||||
.arg("version")
|
||||
.output()
|
||||
.map_err(|e| format!("Failed to execute 'helm -version': {}", e))?;
|
||||
|
||||
@ -151,20 +151,24 @@ impl Topology for K8sAnywhereTopology {
|
||||
}
|
||||
|
||||
async fn ensure_ready(&self) -> Result<Outcome, InterpretError> {
|
||||
let k8s_state = self
|
||||
let k8s_state = self
|
||||
.k8s_state
|
||||
.get_or_try_init(|| self.try_get_or_install_k8s_client())
|
||||
.await?;
|
||||
//{
|
||||
// Some(k8s_state) => Ok(Outcome::success(k8s_state.message.clone())),
|
||||
// None => Err(InterpretError::new("No K8s client could be found or installed".to_string(),
|
||||
// )),
|
||||
//}
|
||||
|
||||
let k8s_state: &K8sState = k8s_state
|
||||
.as_ref()
|
||||
.ok_or(InterpretError::new(
|
||||
"No K8s client could be found or installed".to_string(),
|
||||
))?;
|
||||
|
||||
match self.is_helm_available() {
|
||||
Ok(()) => Ok(Outcome::success("helm available".to_string())),
|
||||
Ok(()) => Ok(Outcome::success(format!(
|
||||
"{} + helm available",
|
||||
k8s_state.message.clone()
|
||||
))),
|
||||
Err(_) => Err(InterpretError::new("helm unavailable".to_string())),
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user