Skip to content

Commit

Permalink
Remove namespace from cluster resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mcruzdev committed Sep 29, 2024
1 parent 2811eec commit 424b3ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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

0 comments on commit 424b3ce

Please sign in to comment.