Skip to content

Commit

Permalink
fix: Report correctly Kubernetes version for OpenShift clusters (#81)
Browse files Browse the repository at this point in the history
Fixes #80

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
  • Loading branch information
jeffmaury authored Jun 4, 2021
1 parent 8aae859 commit c4b1fc4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
******************************************************************************/
package com.redhat.devtools.intellij.common.kubernetes;

import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.VersionInfo;
import io.fabric8.openshift.client.OpenShiftClient;
Expand All @@ -21,7 +22,13 @@ private static String assemble(String major, String minor) {

public static ClusterInfo getClusterInfo(KubernetesClient client) {
if (client.isAdaptable(OpenShiftClient.class)) {
OpenShiftClient oclient = client.adapt(OpenShiftClient.class);
OpenShiftClient oclient;
if (client instanceof OpenShiftClient) {
oclient = (OpenShiftClient) client;
client = new DefaultKubernetesClient(client.getConfiguration());
} else {
oclient = client.adapt(OpenShiftClient.class);
}
VersionInfo oVersion = oclient.getVersion();
return new ClusterInfo(client.getVersion().getGitVersion(), true,
oVersion != null && oVersion.getMajor() != null? assemble(oVersion.getMajor(), oVersion.getMinor()) : "");
Expand Down

0 comments on commit c4b1fc4

Please sign in to comment.