1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Detect rancher distros

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-12-02 15:37:03 +02:00
parent 57d6dfa4b0
commit f7372138a0

View File

@ -8,8 +8,12 @@ export class DistributionDetector extends BaseClusterDetector {
public async detect() { public async detect() {
this.version = await this.getKubernetesVersion(); this.version = await this.getKubernetesVersion();
if (await this.isRancher()) { if (this.isRke()) {
return { value: "rancher", accuracy: 80}; return { value: "rke", accuracy: 80};
}
if (this.isK3s()) {
return { value: "k3s", accuracy: 80};
} }
if (this.isGKE()) { if (this.isGKE()) {
@ -79,13 +83,11 @@ export class DistributionDetector extends BaseClusterDetector {
return this.version.includes("+"); return this.version.includes("+");
} }
protected async isRancher() { protected isRke() {
try { return this.version.includes("-rancher");
const response = await this.k8sRequest(""); }
return response.data.find((api: any) => api?.apiVersion?.group === "meta.cattle.io") !== undefined; protected isK3s() {
} catch (e) { return this.version.includes("+k3s");
return false;
}
} }
} }