Skip to content

Commit ce7e878

Browse files
committed
bump kubernetes-client to 7.0.0 (#247)
Signed-off-by: Andre Dietisheim <[email protected]>
1 parent 9f738b1 commit ce7e878

File tree

11 files changed

+255
-779
lines changed

11 files changed

+255
-779
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ nexusUser=invalid
33
nexusPassword=invalid
44

55
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
6-
ideaVersion=2024.2
6+
ideaVersion=2024.3
77

88
# Gradle Releases -> https://github.com/gradle/gradle/releases
99
gradleVersion=8.5

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
# libraries
33
junit = "4.13.2"
4-
kubernetes-client = "6.12.0"
4+
kubernetes-client = "7.0.0"
55
jackson-core = "2.17.0"
66
commons-lang3 = "3.12.0"
77
commons-exec = "1.3"

src/main/java/com/redhat/devtools/intellij/common/kubernetes/ClusterHelper.java

+19-27
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,32 @@
1616
import io.fabric8.kubernetes.client.VersionInfo;
1717
import io.fabric8.openshift.client.OpenShiftClient;
1818

19-
import java.net.HttpURLConnection;
20-
2119
public class ClusterHelper {
2220

2321
private ClusterHelper() {
2422
//avoid instanciation
2523
}
2624

2725
public static boolean isOpenShift(KubernetesClient client) {
28-
return client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
26+
try {
27+
return client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
28+
} catch (KubernetesClientException e) {
29+
return false;
30+
}
2931
}
3032

3133
public static ClusterInfo getClusterInfo(KubernetesClient client) {
32-
if (client instanceof OpenShiftClient) {
33-
return new ClusterInfo(
34-
getKubernetesVersion((OpenShiftClient) client),
35-
true,
36-
getOpenShiftVersion((OpenShiftClient) client));
37-
38-
} else if (client.adapt(OpenShiftClient.class) != null && client.adapt(OpenShiftClient.class).isSupported()){
34+
OpenShiftClient openShiftClient = getOpenShiftClient(client);
35+
if (openShiftClient != null) {
3936
return new ClusterInfo(
4037
getKubernetesVersion(client),
4138
true,
42-
getOpenShiftVersion(client));
39+
getOpenShiftVersion(openShiftClient));
4340
} else {
4441
return new ClusterInfo(
4542
getKubernetesVersion(client),
4643
false,
4744
"");
48-
49-
}
50-
}
51-
52-
private static String getKubernetesVersion(OpenShiftClient client) {
53-
try {
54-
KubernetesClient kclient = new KubernetesClientBuilder().withConfig(client.getConfiguration()).build();
55-
return getKubernetesVersion(kclient);
56-
} catch (KubernetesClientException e) {
57-
return null;
5845
}
5946
}
6047

@@ -63,18 +50,23 @@ private static String getKubernetesVersion(KubernetesClient client) {
6350
return version != null ? version.getGitVersion() : "";
6451
}
6552

66-
private static String getOpenShiftVersion(KubernetesClient client) {
67-
try {
68-
OpenShiftClient oclient = client.adapt(OpenShiftClient.class);
69-
return getOpenShiftVersion(oclient);
70-
} catch (KubernetesClientException e) {
53+
private static OpenShiftClient getOpenShiftClient(KubernetesClient client) {
54+
if (client instanceof OpenShiftClient) {
55+
return (OpenShiftClient) client;
56+
} else if (isOpenShift(client)) {
57+
return client.adapt(OpenShiftClient.class);
58+
} else {
7159
return null;
7260
}
7361
}
7462

7563
private static String getOpenShiftVersion(OpenShiftClient client) {
7664
VersionInfo version = client.getVersion();
77-
return version != null && version.getMajor() != null ? getVersion(version.getMajor(), version.getMinor()) : "";
65+
if (version != null && version.getMajor() != null) {
66+
return getVersion(version.getMajor(), version.getMinor());
67+
} else {
68+
return "";
69+
}
7870
}
7971

8072
private static String getVersion(String major, String minor) {

0 commit comments

Comments
 (0)