Skip to content

Commit

Permalink
deps: fix: bump Kubernetes Client to 6.6.0 (fixes issues when trace-l…
Browse files Browse the repository at this point in the history
…ogging OpenShift builds)

Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa committed May 4, 2023
1 parent 987b700 commit a478cc5
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Usage:
./scripts/extract-changelog-for-version.sh 1.3.37 5
```
### 1.13-SNAPSHOT
* Fix #2150: Bump Kubernetes Client to 6.6.0 (fixes issues when trace-logging OpenShift builds)

### 1.12.0 (2023-04-03)
* Fix #1179: Move storageClass related functionality out of VolumePermissionEnricher to PersistentVolumeClaimStorageClassEnricher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class OpenShiftApplyTaskTest {

@RegisterExtension
private final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();
public final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();

private MockedConstruction<ClusterAccess> clusterAccessMockedConstruction;
private MockedConstruction<ApplyService> applyServiceMockedConstruction;
Expand All @@ -54,8 +54,7 @@ void setUp() {
final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
when(mock.createDefaultClient()).thenReturn(openShiftClient);
when(openShiftClient.getMasterUrl()).thenReturn(new URL("http://openshiftapps-com-cluster:6443"));
when(openShiftClient.adapt(OpenShiftClient.class)).thenReturn(openShiftClient);
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
});
applyServiceMockedConstruction = mockConstruction(ApplyService.class);
extension = new TestOpenShiftExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
class OpenShiftUndeployTaskTest {

@RegisterExtension
private final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();
public final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();

private MockedConstruction<OpenshiftUndeployService> openshiftUndeployServiceMockedConstruction;
private MockedConstruction<ClusterAccess> clusterAccessMockedConstruction;
Expand All @@ -54,8 +54,7 @@ void setUp() {
clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
when(mock.createDefaultClient()).thenReturn(openShiftClient);
when(openShiftClient.adapt(OpenShiftClient.class)).thenReturn(openShiftClient);
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
});
openshiftUndeployServiceMockedConstruction = mockConstruction(OpenshiftUndeployService.class);
extension = new TestOpenShiftExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static OpenShiftClient asOpenShiftClient(KubernetesClient client) {
}

public static boolean isOpenShift(KubernetesClient client) {
return client.adapt(OpenShiftClient.class).isSupported();
return client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void testAsOpenShiftClientWithNoOpenShift() {
@Test
void testOpenShiftClientWithAdaptableToOpenShift() {
// Given
when(oc.isSupported()).thenReturn(true);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(true);
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
//When
OpenShiftClient result = OpenshiftHelper.asOpenShiftClient(kc);
Expand All @@ -74,8 +74,7 @@ void testOpenShiftClientWithOpenShift() {
@Test
void testIsOpenShiftWhenSupported() {
// Given
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
when(oc.isSupported()).thenReturn(true);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(true);
//When
boolean result = OpenshiftHelper.isOpenShift(kc);
//Then
Expand All @@ -85,8 +84,7 @@ void testIsOpenShiftWhenSupported() {
@Test
void testIsOpenShiftNotSupported() {
// Given
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
when(oc.isSupported()).thenReturn(false);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(false);
//When
boolean result = OpenshiftHelper.isOpenShift(kc);
//Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public boolean isOpenShift() {
String prefix = cause instanceof UnknownHostException ? "Unknown host " : "";
kitLogger.warn("Cannot access cluster for detecting mode: %s%s",
prefix,
cause != null ? cause.getMessage() : exp.getMessage());
cause != null && cause.getMessage() != null ? cause.getMessage() : exp.getMessage());
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void isOpenShiftThrowsExceptionShouldReturnFalse() {
// Then
assertThat(result).isFalse();
verify(logger, times(1))
.warn(startsWith("Cannot access cluster for detecting mode"), eq(""), contains("unknown.example.com"));
.warn(startsWith("Cannot access cluster for detecting mode"), eq(""), eq("An error has occurred."));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void getUndeployServiceInOpenShiftWithValidClient() {
// Given
jKubeServiceHubBuilder.platformMode(RuntimeMode.OPENSHIFT);
try (JKubeServiceHub jKubeServiceHub = jKubeServiceHubBuilder.build()) {
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
// When
final UndeployService result = jKubeServiceHub.getUndeployService();
// Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ void getManifestsToUndeploy() {
// Given
final OpenShiftClient client = mock(OpenShiftClient.class);
when(mockServiceHub.getClient()).thenReturn(client);
when(client.adapt(OpenShiftClient.class)).thenReturn(client);
when(client.isSupported()).thenReturn(true);
when(client.hasApiGroup("openshift.io", false)).thenReturn(true);
// When
final List<File> result = undeployMojo.getManifestsToUndeploy();
// Then
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<version.jmockit>1.49</version.jmockit>
<version.json-smart>2.4.10</version.json-smart> <!-- Transitive dependency required by citrus -->
<version.junit5>5.9.2</version.junit5>
<version.kubernetes-client>6.5.1</version.kubernetes-client>
<version.kubernetes-client>6.6.0</version.kubernetes-client>
<version.license-maven-plugin>4.2</version.license-maven-plugin>
<version.lombok-maven-plugin>1.18.20.0</version.lombok-maven-plugin>
<version.maven-compiler-plugin>3.8.1</version.maven-compiler-plugin>
Expand Down

0 comments on commit a478cc5

Please sign in to comment.