Skip to content

Commit

Permalink
use ClusterHelper#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 Dec 1, 2023
1 parent cb590ba commit ce67aa3
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
******************************************************************************/
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
import io.fabric8.kubernetes.client.Config
import io.fabric8.kubernetes.client.KubernetesClient
import io.fabric8.kubernetes.client.KubernetesClientBuilder
import io.fabric8.kubernetes.client.KubernetesClientException
import io.fabric8.kubernetes.client.http.HttpClient
import io.fabric8.kubernetes.client.impl.AppsAPIGroupClient
import io.fabric8.kubernetes.client.impl.BatchAPIGroupClient
Expand Down Expand Up @@ -81,8 +80,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 (ClusterHelper.isOpenShift(osClient)) {
OSClientAdapter(osClient, kubeClient)
} else {
KubeClientAdapter(kubeClient)
Expand All @@ -101,14 +99,6 @@ abstract class ClientAdapter<C : KubernetesClient>(private val fabric8Client: C)
builder.sslContext(SSLUtils.keyManagers(config), arrayOf(externalTrustManager))
}

private fun isOpenShift(osClient: NamespacedOpenShiftClient): Boolean {
return try {
osClient.isSupported
} catch (e: KubernetesClientException) {
e.isUnauthorized()
}
}

private fun setNamespace(namespace: String?, config: Config) {
if (namespace != null) {
config.namespace = namespace
Expand Down

0 comments on commit ce67aa3

Please sign in to comment.