fix: modifed naming scheme to OpenshiftFamily, K3sFamily, and defaultswitched discovery of openshiftfamily to look for projet.openshift.io
This commit is contained in:
parent
f073b7e5fb
commit
1cec398d4d
@ -48,10 +48,10 @@ struct K8sState {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum K8sFlavour {
|
||||
Okd,
|
||||
K3d,
|
||||
K8s,
|
||||
pub enum KubernetesDistribution {
|
||||
OpenshiftFamily,
|
||||
K3sFamily,
|
||||
Default,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -64,7 +64,7 @@ enum K8sSource {
|
||||
pub struct K8sAnywhereTopology {
|
||||
k8s_state: Arc<OnceCell<Option<K8sState>>>,
|
||||
tenant_manager: Arc<OnceCell<K8sTenantManager>>,
|
||||
flavour: Arc<OnceCell<K8sFlavour>>,
|
||||
flavour: Arc<OnceCell<KubernetesDistribution>>,
|
||||
config: Arc<K8sAnywhereConfig>,
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ impl K8sAnywhereTopology {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_k8s_flavour(&self) -> K8sFlavour {
|
||||
pub async fn get_k8s_distribution(&self) -> KubernetesDistribution {
|
||||
self.flavour
|
||||
.get_or_try_init(async || {
|
||||
let client = self.k8s_client().await.unwrap();
|
||||
@ -197,22 +197,22 @@ impl K8sAnywhereTopology {
|
||||
PreparationError::new(format!("Could not get server version: {}", e))
|
||||
})?;
|
||||
|
||||
let rules: &[&dyn Fn() -> Option<K8sFlavour>] = &[
|
||||
let rules: &[&dyn Fn() -> Option<KubernetesDistribution>] = &[
|
||||
// OpenShift / OKD
|
||||
&|| {
|
||||
discovery
|
||||
.groups()
|
||||
.any(|g| g.name().ends_with("openshift.io"))
|
||||
.then_some(K8sFlavour::Okd)
|
||||
.any(|g| g.name() == "project.openshift.io")
|
||||
.then_some(KubernetesDistribution::OpenshiftFamily)
|
||||
},
|
||||
// K3d / K3s
|
||||
&|| {
|
||||
version
|
||||
.git_version
|
||||
.contains("k3s")
|
||||
.then_some(K8sFlavour::K3d)
|
||||
.then_some(KubernetesDistribution::K3sFamily)
|
||||
},
|
||||
// Vanilla Kubernetes
|
||||
// Fallback Kubernetes K8s
|
||||
&|| {
|
||||
if !discovery
|
||||
.groups()
|
||||
@ -220,7 +220,7 @@ impl K8sAnywhereTopology {
|
||||
&& !version.git_version.contains("k3s")
|
||||
&& !version.git_version.contains("k3d")
|
||||
{
|
||||
Some(K8sFlavour::K8s)
|
||||
Some(KubernetesDistribution::Default)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -228,7 +228,9 @@ impl K8sAnywhereTopology {
|
||||
];
|
||||
|
||||
rules.iter().find_map(|rule| rule()).ok_or_else(|| {
|
||||
PreparationError::new("Unknown Kubernetes cluster flavour".to_string())
|
||||
PreparationError::new(
|
||||
"Unable to detect Kubernetes cluster distribution".to_string(),
|
||||
)
|
||||
})
|
||||
})
|
||||
.await
|
||||
|
Loading…
Reference in New Issue
Block a user