Skip to content

Commit

Permalink
Switch away from deprecated resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Jan 23, 2025
1 parent 13b39da commit 77114c1
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.SecretBuilder;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.quarkus.test.kubernetes.client.KubernetesMockServerTestResource;
import io.quarkus.test.kubernetes.client.KubernetesServerTestResource;

public class CustomKubernetesMockServerTestResource extends KubernetesMockServerTestResource {
public class CustomKubernetesMockServerTestResource extends KubernetesServerTestResource {

// setup the ConfigMap objects that the application expects to lookup configuration from
@Override
public void configureMockServer(KubernetesMockServer mockServer) {
mockServer.expect().get().withPath("/api/v1/namespaces/test/configmaps/cmap1")
protected void configureServer() {
super.configureServer();
System.out.println("HOLLY KUBE configuring mock seerver " + server);
server.expect().get().withPath("/api/v1/namespaces/test/configmaps/cmap1")
.andReturn(200, configMapBuilder("cmap1")
.addToData("dummy", "dummy")
.addToData("overridden.secret", "cm") // will be overridden since secrets have a higher priority
Expand All @@ -24,12 +25,12 @@ public void configureMockServer(KubernetesMockServer mockServer) {
.addToData("application.yaml", "some:\n prop4: val4").build())
.once();

mockServer.expect().get().withPath("/api/v1/namespaces/test/configmaps/cmap2")
server.expect().get().withPath("/api/v1/namespaces/test/configmaps/cmap2")
.andReturn(200, configMapBuilder("cmap2")
.addToData("application.yaml", "some:\n prop4: val4").build())
.once();

mockServer.expect().get().withPath("/api/v1/namespaces/demo/configmaps/cmap3")
server.expect().get().withPath("/api/v1/namespaces/demo/configmaps/cmap3")
.andReturn(200, configMapBuilder("cmap3")
.addToData("dummy", "dummyFromDemo")
.addToData("some.prop1", "val1FromDemo")
Expand All @@ -39,7 +40,7 @@ public void configureMockServer(KubernetesMockServer mockServer) {
.addToData("application.yaml", "some:\n prop4: val4FromDemo").build())
.once();

mockServer.expect().get().withPath("/api/v1/namespaces/test/secrets/s1")
server.expect().get().withPath("/api/v1/namespaces/test/secrets/s1")
.andReturn(200, secretBuilder("s1")
.addToData("dummysecret", encodeValue("dummysecret"))
.addToData("overridden.secret", encodeValue("secret"))
Expand All @@ -49,7 +50,7 @@ public void configureMockServer(KubernetesMockServer mockServer) {
.addToData("application.yaml", encodeValue("secret:\n prop4: val4")).build())
.once();

mockServer.expect().get().withPath("/api/v1/namespaces/demo/secrets/s1")
server.expect().get().withPath("/api/v1/namespaces/demo/secrets/s1")
.andReturn(200, secretBuilder("s1")
.addToData("dummysecret", encodeValue("dummysecretFromDemo"))
.addToData("overridden.secret", encodeValue("secretFromDemo"))
Expand Down

0 comments on commit 77114c1

Please sign in to comment.