diff --git a/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/access/ClusterAccessTest.java b/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/access/ClusterAccessTest.java index 459aed3083..475e86f0e6 100644 --- a/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/access/ClusterAccessTest.java +++ b/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/access/ClusterAccessTest.java @@ -13,70 +13,53 @@ */ package org.eclipse.jkube.kit.config.access; -import java.net.UnknownHostException; -import java.util.function.Consumer; - -import org.eclipse.jkube.kit.common.KitLogger; - -import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.api.model.APIGroupListBuilder; import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.KubernetesClientException; +import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; +import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; import io.fabric8.openshift.client.OpenShiftClient; -import org.junit.jupiter.api.AfterEach; +import org.eclipse.jkube.kit.common.KitLogger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.MockedConstruction; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockConstruction; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +@EnableKubernetesMockClient(https = false) class ClusterAccessTest { private KitLogger logger; - private MockedConstruction kubernetesClientMockedConstruction; - private Consumer onInstantiate; + private KubernetesMockServer mockServer; + private ClusterConfiguration clusterConfiguration; @BeforeEach void setUp() { logger = spy(new KitLogger.SilentLogger()); - onInstantiate = oc -> { - }; - kubernetesClientMockedConstruction = mockConstruction(DefaultKubernetesClient.class, (mock, ctx) -> { - final OpenShiftClient oc = mock(OpenShiftClient.class); - when(mock.adapt(OpenShiftClient.class)).thenReturn(oc); - onInstantiate.accept(oc); - }); - } - - @AfterEach - void tearDown() { - kubernetesClientMockedConstruction.close(); + clusterConfiguration = ClusterConfiguration.builder() + .masterUrl(mockServer.url("/")) + .build(); } @Test void isOpenShiftOpenShiftClusterShouldReturnTrue() { // Given - onInstantiate = oc -> when(oc.isSupported()).thenReturn(true); + mockServer.expect().get().withPath("/apis").andReturn(200, + new APIGroupListBuilder().addNewGroup().withName("project.openshift.io").withApiVersion("v1").endGroup().build()).once(); // When - final boolean result = new ClusterAccess(logger, null).isOpenShift(); + final boolean result = new ClusterAccess(logger, clusterConfiguration).isOpenShift(); // Then assertThat(result).isTrue(); } @Test void isOpenShiftKubernetesClusterShouldReturnFalse() { - // Given - onInstantiate = oc -> when(oc.isSupported()).thenReturn(false); // When - final boolean result = new ClusterAccess(logger, null).isOpenShift(); + final boolean result = new ClusterAccess(logger, clusterConfiguration).isOpenShift(); // Then assertThat(result).isFalse(); } @@ -84,20 +67,19 @@ void isOpenShiftKubernetesClusterShouldReturnFalse() { @Test void isOpenShiftThrowsExceptionShouldReturnFalse() { // Given - onInstantiate = oc -> when(oc.isSupported()) - .thenThrow(new KubernetesClientException("ERROR", new UnknownHostException())); + clusterConfiguration = ClusterConfiguration.builder().masterUrl("https://unknown.example.com").build(); // When - final boolean result = new ClusterAccess(logger, null).isOpenShift(); + final boolean result = new ClusterAccess(logger, clusterConfiguration).isOpenShift(); // Then assertThat(result).isFalse(); verify(logger, times(1)) - .warn(startsWith("Cannot access cluster for detecting mode"), eq("Unknown host "), isNull()); + .warn(startsWith("Cannot access cluster for detecting mode"), eq(""), contains("unknown.example.com")); } @Test void createDefaultClientInKubernetesShouldReturnKubernetesClient() { // When - final KubernetesClient result = new ClusterAccess(logger, null).createDefaultClient(); + final KubernetesClient result = new ClusterAccess(logger, clusterConfiguration).createDefaultClient(); // Then assertThat(result).isNotNull().isNotInstanceOf(OpenShiftClient.class); } @@ -105,9 +87,10 @@ void createDefaultClientInKubernetesShouldReturnKubernetesClient() { @Test void createDefaultClientInOpenShiftShouldReturnOpenShiftClient() { // Given - onInstantiate = oc -> when(oc.isSupported()).thenReturn(true); + mockServer.expect().get().withPath("/apis").andReturn(200, + new APIGroupListBuilder().addNewGroup().withName("project.openshift.io").withApiVersion("v1").endGroup().build()).once(); // When - final KubernetesClient result = new ClusterAccess(logger, null).createDefaultClient(); + final KubernetesClient result = new ClusterAccess(logger, clusterConfiguration).createDefaultClient(); // Then assertThat(result).isNotNull().isInstanceOf(OpenShiftClient.class); } diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java index 925238582d..ad6d6c0a40 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/ApplyServiceTest.java @@ -304,7 +304,7 @@ void processCustomEntitiesRecreateModeTrue() throws Exception { .addToResources(virtualServiceResource(), gatewayResource()).build())) .times(2); mockServer.expect().get() - .withPath("/apis/networking.istio.io/v1alpha3/namespaces/default/gateways?fieldSelector=metadata.name%3Dmygateway-https") + .withPath("/apis/networking.istio.io/v1alpha3/namespaces/default/gateways?fieldSelector=metadata.name%3Dmygateway-https&resourceVersion=0") .andReturn(HTTP_OK, new GenericKubernetesResourceBuilder() .withApiVersion("networking.istio.io/v1alpha3") .withKind("Gateway") @@ -312,7 +312,7 @@ void processCustomEntitiesRecreateModeTrue() throws Exception { .build()) .once(); mockServer.expect().get() - .withPath("/apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices?fieldSelector=metadata.name%3Dreviews-route") + .withPath("/apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices?fieldSelector=metadata.name%3Dreviews-route&resourceVersion=0") .andReturn(HTTP_OK, new GenericKubernetesResourceBuilder() .withApiVersion("networking.istio.io/v1alpha3") .withKind("VirtualService") diff --git a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildServiceIntegrationTest.java b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildServiceIntegrationTest.java index 545d8f1c7c..ece828c7a9 100644 --- a/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildServiceIntegrationTest.java +++ b/jkube-kit/config/service/src/test/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildServiceIntegrationTest.java @@ -38,7 +38,6 @@ import org.eclipse.jkube.kit.common.KitLogger; import org.eclipse.jkube.kit.common.RegistryConfig; import org.eclipse.jkube.kit.common.archive.ArchiveCompression; -import org.eclipse.jkube.kit.common.util.OpenshiftHelper; import org.eclipse.jkube.kit.config.image.ImageConfiguration; import org.eclipse.jkube.kit.config.image.build.BuildConfiguration; import org.eclipse.jkube.kit.config.image.build.JKubeBuildStrategy; @@ -70,7 +69,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.mockito.MockedConstruction; -import org.mockito.MockedStatic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -79,7 +77,6 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -92,8 +89,6 @@ class OpenshiftBuildServiceIntegrationTest { private JKubeServiceHub jKubeServiceHub; - private MockedStatic openshiftHelper; - private MockedConstruction jKubeBuildTarArchiver; private File baseDirectory; @@ -114,7 +109,7 @@ class OpenshiftBuildServiceIntegrationTest { private BuildServiceConfig.BuildServiceConfigBuilder dockerImageConfig; - private ResourceConfig mockedResourceConfig; + private ResourceConfig resourceConfig; @BeforeEach void init(@TempDir Path temporaryFolder) throws Exception { @@ -129,16 +124,11 @@ void init(@TempDir Path temporaryFolder) throws Exception { final File dockerFile = new File(baseDir, "Docker.tar"); FileUtils.touch(dockerFile); - openshiftHelper = mockStatic(OpenshiftHelper.class); - openshiftHelper.when(() -> OpenshiftHelper.isOpenShift(eq(client))) - .thenReturn(true); - jKubeBuildTarArchiver = mockConstruction(JKubeBuildTarArchiver.class, (mock, ctx) -> when(mock.createArchive(any(File.class), any(BuildDirs.class), eq(ArchiveCompression.none))) .thenReturn(emptyDockerBuildTar)); - mockedResourceConfig = mock(ResourceConfig.class, RETURNS_DEEP_STUBS); - when(mockedResourceConfig.getNamespace()).thenReturn("ns1"); + resourceConfig = ResourceConfig.builder().namespace("ns1").build(); jKubeServiceHub = mock(JKubeServiceHub.class, RETURNS_DEEP_STUBS); when(jKubeServiceHub.getClient()).thenReturn(client); @@ -166,7 +156,7 @@ void init(@TempDir Path temporaryFolder) throws Exception { .buildDirectory(baseDir) .buildRecreateMode(BuildRecreateMode.none) .s2iBuildNameSuffix("-s2i-suffix2") - .resourceConfig(mockedResourceConfig) + .resourceConfig(resourceConfig) .jKubeBuildStrategy(JKubeBuildStrategy.s2i); defaultConfigSecret = defaultConfig.build().toBuilder().openshiftPullSecret("pullsecret-fabric8"); @@ -184,7 +174,6 @@ void init(@TempDir Path temporaryFolder) throws Exception { void tearDown() { Serialization.jsonMapper().enable(SerializationFeature.INDENT_OUTPUT); jKubeBuildTarArchiver.close(); - openshiftHelper.close(); } @Test @@ -198,7 +187,7 @@ void successfulBuild() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); assertThat(containsRequest("imagestreams")).isTrue(); } @@ -282,7 +271,7 @@ void successfulBuildNoS2iSuffix() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); } @@ -293,7 +282,7 @@ void dockerBuild() throws Exception { .buildRecreateMode(BuildRecreateMode.none) .s2iBuildNameSuffix("-docker") .jKubeBuildStrategy(JKubeBuildStrategy.docker) - .resourceConfig(mockedResourceConfig).build()); + .resourceConfig(resourceConfig).build()); final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false, false); new OpenshiftBuildService(jKubeServiceHub).build(image); @@ -301,7 +290,7 @@ void dockerBuild() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); } @@ -312,7 +301,7 @@ void dockerBuildWithMultiComponentImageName() throws Exception { .buildRecreateMode(BuildRecreateMode.none) .s2iBuildNameSuffix("-docker") .jKubeBuildStrategy(JKubeBuildStrategy.docker) - .resourceConfig(mockedResourceConfig).build()); + .resourceConfig(resourceConfig).build()); image.setName("docker.io/registry/component1/component2/name:tag"); final WebServerEventCollector collector = prepareMockServer("component1-component2-name", dockerConfig, true, false, false, false); @@ -322,7 +311,7 @@ void dockerBuildWithMultiComponentImageName() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"component1-component2-name-docker\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"component1-component2-name:tag\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"component1-component2-name-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"component1-component2-name:tag\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); } @@ -332,7 +321,7 @@ void dockerBuildNoS2iSuffix() throws Exception { .buildDirectory(baseDir) .buildRecreateMode(BuildRecreateMode.none) .jKubeBuildStrategy(JKubeBuildStrategy.docker) - .resourceConfig(mockedResourceConfig) + .resourceConfig(resourceConfig) .build()); final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false, false); @@ -341,7 +330,7 @@ void dockerBuildNoS2iSuffix() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"},\"noCache\":false},\"type\":\"Docker\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); } @@ -352,7 +341,7 @@ void dockerBuildFromExt() throws Exception { .buildRecreateMode(BuildRecreateMode.none) .s2iBuildNameSuffix("-docker") .jKubeBuildStrategy(JKubeBuildStrategy.docker) - .resourceConfig(mockedResourceConfig) + .resourceConfig(resourceConfig) .build()); final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false, false); @@ -373,7 +362,7 @@ void dockerBuildFromExt() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(8); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"app:1.2-1\",\"namespace\":\"my-project\"},\"noCache\":true},\"type\":\"Docker\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"app:1.2-1\",\"namespace\":\"my-project\"},\"noCache\":true},\"type\":\"Docker\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); } @@ -415,9 +404,11 @@ void successfulBuildWithResourceConfig() throws Exception { final Map limitsMap = new HashMap<>(); limitsMap.put("cpu", "100m"); limitsMap.put("memory", "256Mi"); - when(mockedResourceConfig.getOpenshiftBuildConfig()).thenReturn(OpenshiftBuildConfig.builder().limits(limitsMap).build()); + resourceConfig = resourceConfig.toBuilder() + .openshiftBuildConfig(OpenshiftBuildConfig.builder().limits(limitsMap).build()) + .build(); final BuildServiceConfig config = withBuildServiceConfig(defaultConfig - .resourceConfig(mockedResourceConfig).build()); + .resourceConfig(resourceConfig).build()); final WebServerEventCollector collector = prepareMockServer(config, true, false, false, false); new OpenshiftBuildService(jKubeServiceHub).build(image); @@ -450,7 +441,7 @@ void successfulDockerImageOutputBuild() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(7); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"DockerImage\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"DockerImage\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); assertThat(containsRequest("imagestreams")).isFalse(); } @@ -466,7 +457,7 @@ void successfulDockerImageOutputBuildSecret() throws Exception { assertThat(mockServer.getRequestCount()).isGreaterThan(7); collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed"); assertThat(collector.getBodies().get(1)) - .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\",\"namespace\":\"ns1\"},\"spec\":{\"output\":{\"pushSecret\":{\"name\":\"pushsecret-fabric8\"},\"to\":{\"kind\":\"DockerImage\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); + .isEqualTo("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-s2i-suffix2\"},\"spec\":{\"output\":{\"pushSecret\":{\"name\":\"pushsecret-fabric8\"},\"to\":{\"kind\":\"DockerImage\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"sourceStrategy\":{\"forcePull\":false,\"from\":{\"kind\":\"DockerImage\",\"name\":\"myapp\"}},\"type\":\"Source\"}}}"); collector.assertEventsNotRecorded("patch-build-config"); assertThat(containsRequest("imagestreams")).isFalse(); } diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java index 6e79dac060..ed7529147f 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/DockerRegistrySecretEnricherTest.java @@ -111,7 +111,7 @@ void dockerRegistryWithBadKind() { KubernetesList expected = builder.build(); enricher.create(PlatformMode.kubernetes, builder); - assertThat(builder.build()).isEqualTo(expected); + assertThat(builder.build().getItems()).isEqualTo(expected.getItems()); } @Test @@ -125,7 +125,7 @@ void dockerRegistryWithBadAnnotation() { KubernetesList expected = builder.build(); enricher.create(PlatformMode.kubernetes, builder); - assertThat(builder.build()).isEqualTo(expected); + assertThat(builder.build().getItems()).isEqualTo(expected.getItems()); } private Secret createBaseSecret(boolean withAnnotation, String annotationValue) { diff --git a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java index ce21b52b31..f6069859bf 100644 --- a/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java +++ b/jkube-kit/resource/service/src/test/java/org/eclipse/jkube/kit/resource/service/WriteUtilTest.java @@ -99,7 +99,7 @@ void writeResourcesIndividualAndCompositeWithResourcesShouldWriteAll() throws IO klb.addToItems( new ConfigMapBuilder().withNewMetadata().withName("cm-1").endMetadata().build(), new SecretBuilder().withNewMetadata().withName("secret-1").endMetadata().build(), - new SecretBuilder().withNewMetadata().withName(" ").withClusterName("skipped (blank name)").endMetadata().build() + new SecretBuilder().withNewMetadata().withName(" ").endMetadata().build() ); // When WriteUtil.writeResourcesIndividualAndComposite(klb.build(), resourceFileBase, null, log); diff --git a/pom.xml b/pom.xml index 0758750cd2..a5d082e5d1 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ 1.49 2.4.8 5.9.1 - 6.1.1 + 6.4.0 3.0 1.18.20.0 3.8.1