Skip to content

Commit

Permalink
use ClientHelper#isOpenShift in intellij-common
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Nov 30, 2023
1 parent cb590ba commit 0f99496
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,8 +82,7 @@ abstract class ClientAdapter<C : KubernetesClient>(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)
Expand All @@ -102,11 +102,7 @@ abstract class ClientAdapter<C : KubernetesClient>(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) {
Expand Down

0 comments on commit 0f99496

Please sign in to comment.