Skip to content

Commit

Permalink
Merge pull request #20098 from ioforks/rbac-labels
Browse files Browse the repository at this point in the history
RoleBinding is now properly labelled / annotated
  • Loading branch information
gastaldi authored Sep 13, 2021
2 parents 2d8e7bb + c0590e8 commit 1d94761
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,15 @@ public static List<DecoratorBuildItem> createDecorators(Optional<Project> projec
result.add(new DecoratorBuildItem(new ApplyServiceAccountNamedDecorator()));
result.add(new DecoratorBuildItem(new AddServiceAccountResourceDecorator()));
roles.forEach(r -> result.add(new DecoratorBuildItem(new AddRoleResourceDecorator(r))));
roleBindings.forEach(rb -> result.add(new DecoratorBuildItem(
new AddRoleBindingResourceDecorator(rb.getName(), null, rb.getRole(), rb.isClusterWide()
? AddRoleBindingResourceDecorator.RoleKind.ClusterRole
: AddRoleBindingResourceDecorator.RoleKind.Role))));
roleBindings.forEach(rb -> {
result.add(new DecoratorBuildItem(new AddRoleBindingResourceDecorator(rb.getName(), null, rb.getRole(),
rb.isClusterWide() ? AddRoleBindingResourceDecorator.RoleKind.ClusterRole
: AddRoleBindingResourceDecorator.RoleKind.Role)));
labels.forEach(l -> {
result.add(new DecoratorBuildItem(
new AddLabelDecorator(rb.getName(), l.getKey(), l.getValue(), "RoleBinding")));
});
});
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.quarkus.it.kubernetes;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -50,6 +51,7 @@ public void assertGeneratedResources() throws IOException {

assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
assertThat(d.getMetadata()).satisfies(m -> {
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getName()).isEqualTo("kubernetes-with-rbac-and-namespace");
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
quarkus.kubernetes.namespace=my-namespace
quarkus.kubernetes.namespace=my-namespace
quarkus.kubernetes.labels.foo=bar

0 comments on commit 1d94761

Please sign in to comment.