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

fix: bump kubernetes- and openshift-client to 7.0.0 (#247) #248

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/IJ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
IJ: [2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2]
IJ: [2022.3, 2023.1, 2023.2, 2023.3, 2024.1, 2024.2, 2024.3]

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
Expand Down Expand Up @@ -59,9 +60,8 @@ dependencies {
// for unit tests
testImplementation(libs.junit)
testImplementation(libs.assertj.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.core)
testImplementation(libs.opentest4j) // known issue: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#missing-opentest4j-dependency-in-test-framework

}

tasks {
Expand All @@ -73,6 +73,9 @@ tasks {
useJUnit()
systemProperty("tools.dl.path", temporaryDir)
jvmArgs("-Djava.awt.headless=true")
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
}

withType<Test> {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nexusUser=invalid
nexusPassword=invalid

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
ideaVersion=2024.2
ideaVersion=2024.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also update the ci to validate against this version ( i know it's this one used in OS-matrix build, but this will provide us verifier reports )


# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.5
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
# libraries
junit = "4.13.2"
kubernetes-client = "6.12.0"
kubernetes-client = "7.0.0"
jackson-core = "2.17.0"
commons-lang3 = "3.12.0"
commons-exec = "1.3"
common-lang = "3.9.4"
assertj-core = "3.22.0"
mockito-inline = "4.5.1"
mockito-core = "5.14.2"
opentest4j = "1.3.0"

# plugins
Expand All @@ -22,7 +22,7 @@ kubernetes-httpclient-okhttp = { group = "io.fabric8", name = "kubernetes-httpcl
jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson-core" }
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commons-lang3" }
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj-core" }
mockito-inline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito-inline" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" }
commons-exec = { group = "org.apache.commons", name = "commons-exec", version.ref = "commons-exec" }
common-lang = { group = "com.twelvemonkeys.common", name = "common-lang", version.ref = "common-lang" }
opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,33 @@
import io.fabric8.kubernetes.client.VersionInfo;
import io.fabric8.openshift.client.OpenShiftClient;

import java.net.HttpURLConnection;

public class ClusterHelper {

private ClusterHelper() {
//avoid instanciation
}

public static boolean isOpenShift(KubernetesClient client) {
return client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
try {
return client != null
&& client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
} catch (KubernetesClientException e) {
return false;
}
}

public static ClusterInfo getClusterInfo(KubernetesClient client) {
if (client instanceof OpenShiftClient) {
return new ClusterInfo(
getKubernetesVersion((OpenShiftClient) client),
true,
getOpenShiftVersion((OpenShiftClient) client));

} else if (client.adapt(OpenShiftClient.class) != null && client.adapt(OpenShiftClient.class).isSupported()){
OpenShiftClient openShiftClient = getOpenShiftClient(client);
if (openShiftClient != null) {
return new ClusterInfo(
getKubernetesVersion(client),
true,
getOpenShiftVersion(client));
getOpenShiftVersion(openShiftClient));
} else {
return new ClusterInfo(
getKubernetesVersion(client),
false,
"");

}
}

private static String getKubernetesVersion(OpenShiftClient client) {
try {
KubernetesClient kclient = new KubernetesClientBuilder().withConfig(client.getConfiguration()).build();
return getKubernetesVersion(kclient);
} catch (KubernetesClientException e) {
return null;
}
}

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

private static String getOpenShiftVersion(KubernetesClient client) {
try {
OpenShiftClient oclient = client.adapt(OpenShiftClient.class);
return getOpenShiftVersion(oclient);
} catch (KubernetesClientException e) {
private static OpenShiftClient getOpenShiftClient(KubernetesClient client) {
if (client instanceof OpenShiftClient) {
return (OpenShiftClient) client;
} else if (isOpenShift(client)) {
return client.adapt(OpenShiftClient.class);
} else {
return null;
}
}

private static String getOpenShiftVersion(OpenShiftClient client) {
VersionInfo version = client.getVersion();
return version != null && version.getMajor() != null ? getVersion(version.getMajor(), version.getMinor()) : "";
if (version != null && version.getMajor() != null) {
return getVersion(version.getMajor(), version.getMinor());
} else {
return "";
}
}

private static String getVersion(String major, String minor) {
Expand Down
Loading
Loading