From 4ea265671bb3010d4a61f2a5a477e406c432577d Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Mon, 7 Dec 2020 09:17:19 +0200 Subject: [PATCH] Detect Openshift (#1625) Signed-off-by: Jari Kolehmainen --- .../cluster-detectors/distribution-detector.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/cluster-detectors/distribution-detector.ts b/src/main/cluster-detectors/distribution-detector.ts index b496f2ce00..be0cadb1bd 100644 --- a/src/main/cluster-detectors/distribution-detector.ts +++ b/src/main/cluster-detectors/distribution-detector.ts @@ -60,6 +60,10 @@ export class DistributionDetector extends BaseClusterDetector { return { value: "custom", accuracy: 10}; } + if (await this.isOpenshift()) { + return { value: "openshift", accuracy: 90}; + } + return { value: "unknown", accuracy: 10}; } @@ -122,4 +126,14 @@ export class DistributionDetector extends BaseClusterDetector { protected isK3s() { 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; + } + } }