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

Add decorator to remove namespace from ClusterRole and ClusterRoleBin… #43579

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -43,4 +43,10 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(namespace);
}

@Override
public Class<? extends Decorator>[] before() {
// this is necessary because cluster resources does not have namespace.
return new Class[] { AddClusterRoleBindingResourceDecorator.class, AddClusterRoleResourceDecorator.class };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void assertGeneratedResources() throws IOException {

// secret-reader assertions
ClusterRole secretReaderRole = getClusterRoleByName(kubernetesList, "secret-reader");
assertThat(secretReaderRole.getMetadata().getNamespace()).isNull();
assertThat(secretReaderRole.getRules()).satisfiesOnlyOnce(r -> {
assertThat(r.getApiGroups()).containsExactly("");
assertThat(r.getResources()).containsExactly("secrets");
Expand Down Expand Up @@ -111,6 +112,7 @@ public void assertGeneratedResources() throws IOException {
assertEquals("Group", clusterSubject.getKind());
assertEquals("manager", clusterSubject.getName());
assertEquals("rbac.authorization.k8s.io", clusterSubject.getApiGroup());
assertThat(clusterRoleBinding.getMetadata().getNamespace()).isNull();
}

private int lastIndexOfKind(String content, String... kinds) {
Expand Down