Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ClusterHelper#isOpenShift in intellij-common #674

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading