From 249c153bb3a09fdc62964f70c81f9f634d749d6e Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis <geoand@gmail.com> Date: Wed, 22 Jun 2022 12:12:16 +0300 Subject: [PATCH] Allow overriding of app.openshift.io/runtime label Fixes: #26273 --- .../io/quarkus/kubernetes/deployment/OpenshiftProcessor.java | 5 ++++- .../test/java/io/quarkus/it/kubernetes/OpenshiftV4Test.java | 2 +- .../src/test/resources/openshift-v4.properties | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java index deb446fbca881..2027aee823103 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java @@ -246,7 +246,10 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic }); result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyImagePullPolicyDecorator(name, config.getImagePullPolicy()))); - result.add(new DecoratorBuildItem(OPENSHIFT, new AddLabelDecorator(name, OPENSHIFT_APP_RUNTIME, QUARKUS))); + + if (labels.stream().noneMatch(l -> l.getKey().equals(OPENSHIFT_APP_RUNTIME))) { + result.add(new DecoratorBuildItem(OPENSHIFT, new AddLabelDecorator(name, OPENSHIFT_APP_RUNTIME, QUARKUS))); + } Stream.concat(config.convertToBuildItems().stream(), envs.stream().filter(e -> e.getTarget() == null || OPENSHIFT.equals(e.getTarget()))).forEach(e -> { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftV4Test.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftV4Test.java index e839ae13726ef..28e4c4f5c48ae 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftV4Test.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftV4Test.java @@ -43,7 +43,7 @@ public void assertGeneratedResources() throws IOException { assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> { assertThat(h.getMetadata()).satisfies(m -> { assertThat(m.getName()).isEqualTo("openshift-v4"); - assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus"); + assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("test"); assertThat(m.getLabels().get("app.kubernetes.io/name")).isEqualTo("openshift-v4"); assertThat(m.getLabels().get("app")).isNull(); assertThat(m.getNamespace()).isNull(); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v4.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v4.properties index b1345eed2b92b..e83c675f79905 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v4.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v4.properties @@ -1,2 +1,3 @@ quarkus.kubernetes.deployment-target=openshift -quarkus.openshift.flavor=v4 \ No newline at end of file +quarkus.openshift.flavor=v4 +quarkus.openshift.labels."app.openshift.io/runtime"=test