From 8ce1c30d565d83b7c6fe85d881ddd5ecca7653a9 Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Thu, 30 Nov 2023 20:34:00 +0100 Subject: [PATCH] use ClusterHelper#isOpenShift in intellij-common Signed-off-by: Andre Dietisheim --- .../intellij/kubernetes/model/client/ClientAdapter.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/client/ClientAdapter.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/client/ClientAdapter.kt index 0dc05664a..77fe69819 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/client/ClientAdapter.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/client/ClientAdapter.kt @@ -10,6 +10,7 @@ ******************************************************************************/ package com.redhat.devtools.intellij.kubernetes.model.client +import com.redhat.devtools.intellij.common.kubernetes.ClusterHelper import com.redhat.devtools.intellij.kubernetes.model.client.ssl.IDEATrustManager import com.redhat.devtools.intellij.kubernetes.model.util.isUnauthorized import io.fabric8.kubernetes.client.Client @@ -81,8 +82,7 @@ abstract class ClientAdapter(private val fabric8Client: C) } .build() val osClient = kubeClient.adapt(NamespacedOpenShiftClient::class.java) - val isOpenShift = isOpenShift(osClient) - return if (isOpenShift) { + return if (isOpenShift(osClient)) { OSClientAdapter(osClient, kubeClient) } else { KubeClientAdapter(kubeClient) @@ -102,11 +102,7 @@ abstract class ClientAdapter(private val fabric8Client: C) } private fun isOpenShift(osClient: NamespacedOpenShiftClient): Boolean { - return try { - osClient.isSupported - } catch (e: KubernetesClientException) { - e.isUnauthorized() - } + return ClusterHelper.isOpenShift(osClient) } private fun setNamespace(namespace: String?, config: Config) {