Skip to content

Commit 109628c

Browse files
committed
bump kubernetes-client to 7.0.0 (#247)
* changed API for ConfigWatcher#Listener#onUpdate * removed references to specific config file, use files collected by client instead * bumped mockito to support jdk21 Signed-off-by: Andre Dietisheim <[email protected]>
1 parent 9d52f06 commit 109628c

File tree

13 files changed

+414
-774
lines changed

13 files changed

+414
-774
lines changed

.github/workflows/IJ.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
IJ: [2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2]
17+
IJ: [2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2, 2024.3]
1818

1919
steps:
2020
- uses: actions/checkout@v4

build.gradle.kts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
12
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
23
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
34
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
@@ -59,9 +60,8 @@ dependencies {
5960
// for unit tests
6061
testImplementation(libs.junit)
6162
testImplementation(libs.assertj.core)
62-
testImplementation(libs.mockito.inline)
63+
testImplementation(libs.mockito.core)
6364
testImplementation(libs.opentest4j) // known issue: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#missing-opentest4j-dependency-in-test-framework
64-
6565
}
6666

6767
tasks {
@@ -73,6 +73,9 @@ tasks {
7373
useJUnit()
7474
systemProperty("tools.dl.path", temporaryDir)
7575
jvmArgs("-Djava.awt.headless=true")
76+
testLogging {
77+
exceptionFormat = TestExceptionFormat.FULL
78+
}
7679
}
7780

7881
withType<Test> {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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"
88
common-lang = "3.9.4"
99
assertj-core = "3.22.0"
10-
mockito-inline = "4.5.1"
10+
mockito-core = "5.14.2"
1111
opentest4j = "1.3.0"
1212

1313
# plugins
@@ -22,7 +22,7 @@ kubernetes-httpclient-okhttp = { group = "io.fabric8", name = "kubernetes-httpcl
2222
jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson-core" }
2323
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commons-lang3" }
2424
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj-core" }
25-
mockito-inline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito-inline" }
25+
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" }
2626
commons-exec = { group = "org.apache.commons", name = "commons-exec", version.ref = "commons-exec" }
2727
common-lang = { group = "com.twelvemonkeys.common", name = "common-lang", version.ref = "common-lang" }
2828
opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }

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

+20-27
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,33 @@
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 != null
28+
&& client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
29+
} catch (KubernetesClientException e) {
30+
return false;
31+
}
2932
}
3033

3134
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()){
35+
OpenShiftClient openShiftClient = getOpenShiftClient(client);
36+
if (openShiftClient != null) {
3937
return new ClusterInfo(
4038
getKubernetesVersion(client),
4139
true,
42-
getOpenShiftVersion(client));
40+
getOpenShiftVersion(openShiftClient));
4341
} else {
4442
return new ClusterInfo(
4543
getKubernetesVersion(client),
4644
false,
4745
"");
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;
5846
}
5947
}
6048

@@ -63,18 +51,23 @@ private static String getKubernetesVersion(KubernetesClient client) {
6351
return version != null ? version.getGitVersion() : "";
6452
}
6553

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

7564
private static String getOpenShiftVersion(OpenShiftClient client) {
7665
VersionInfo version = client.getVersion();
77-
return version != null && version.getMajor() != null ? getVersion(version.getMajor(), version.getMinor()) : "";
66+
if (version != null && version.getMajor() != null) {
67+
return getVersion(version.getMajor(), version.getMinor());
68+
} else {
69+
return "";
70+
}
7871
}
7972

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

0 commit comments

Comments
 (0)