Skip to content

Commit

Permalink
When disabling add-version-to-label-selectors in k8s, don't remove ve…
Browse files Browse the repository at this point in the history
…rsion label

The version label should remain, only the labels in the selectors should
be removed

Fixes: quarkusio#30100
  • Loading branch information
geoand committed Jan 3, 2023
1 parent 4fa6890 commit b45c79c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator;
import io.dekorate.kubernetes.decorator.RemoveFromMatchingLabelsDecorator;
import io.dekorate.kubernetes.decorator.RemoveFromSelectorDecorator;
import io.dekorate.kubernetes.decorator.RemoveLabelDecorator;
import io.dekorate.project.BuildInfo;
import io.dekorate.project.FileProjectFactory;
import io.dekorate.project.Project;
Expand Down Expand Up @@ -208,13 +207,11 @@ private static Collection<DecoratorBuildItem> createLabelDecorators(Optional<Pro
});

if (!config.isAddVersionToLabelSelectors()) {
result.add(new DecoratorBuildItem(target, new RemoveLabelDecorator(name, Labels.VERSION)));
result.add(new DecoratorBuildItem(target, new RemoveFromSelectorDecorator(name, Labels.VERSION)));
result.add(new DecoratorBuildItem(target, new RemoveFromMatchingLabelsDecorator(name, Labels.VERSION)));
}

if (!config.isAddNameToLabelSelectors()) {
result.add(new DecoratorBuildItem(target, new RemoveLabelDecorator(name, Labels.NAME)));
result.add(new DecoratorBuildItem(target, new RemoveFromSelectorDecorator(name, Labels.NAME)));
result.add(new DecoratorBuildItem(target, new RemoveFromMatchingLabelsDecorator(name, Labels.NAME)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void assertGeneratedResources() throws IOException {
assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> {
assertThat(d.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("test-it");
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getLabels()).contains(entry("foo", "bar"))
.containsKey("app.kubernetes.io/version"); // make sure the version was not removed from the labels
assertThat(m.getNamespace()).isEqualTo("applications");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ 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("test-it");
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getLabels()).contains(entry("foo", "bar"))
.containsKey("app.kubernetes.io/version"); // make sure the version was not removed from the labels
assertThat(m.getNamespace()).isEqualTo("applications");
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
Expand Down

0 comments on commit b45c79c

Please sign in to comment.