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

Detect Openshift (#1625)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-12-07 09:17:19 +02:00 committed by GitHub
parent dbf49cc1b0
commit 4ea265671b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,10 @@ export class DistributionDetector extends BaseClusterDetector {
return { value: "custom", accuracy: 10}; return { value: "custom", accuracy: 10};
} }
if (await this.isOpenshift()) {
return { value: "openshift", accuracy: 90};
}
return { value: "unknown", accuracy: 10}; return { value: "unknown", accuracy: 10};
} }
@ -122,4 +126,14 @@ export class DistributionDetector extends BaseClusterDetector {
protected isK3s() { protected isK3s() {
return this.version.includes("+k3s"); return this.version.includes("+k3s");
} }
protected async isOpenshift() {
try {
const response = await this.k8sRequest("");
return response.paths?.includes("/apis/project.openshift.io");
} catch (e) {
return false;
}
}
} }