Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When disabling name and version for label selected in k8s, don't remove from labels #30142

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geoand (working on the 2.13 backports with @rsvoboda) we saw that you are doing the same fix for the name but we don't see it mentioned anywhere. You positive it needs fixing too? If so could you adjust the title of the PR so that the change is properly documented in the changelog?

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am yeah, it's the same exact logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title updated accordingly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried to backport it to 2.13 but this method doesn't exist at all (and I don't see something similar in this class). So either we should backport the previous fix that introduced this method or we can skip it.

I will let you and @Sgitario decide what to do with it. Please ping me loudly on Zulip if an action on my side is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let you and @Sgitario decide what to do with it.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that disabling the selectors is a super important feature that we should backport to 2.13, on the other hand, the changes are not very complex.
I would say to not backport the feature and hence these changes.

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