Skip to content

Commit

Permalink
fix: add patch for creator dependent resource role (#670)
Browse files Browse the repository at this point in the history
this is needed when it is created by SSA
  • Loading branch information
csviri authored Aug 8, 2023
1 parent 5bbb12a commit 94d4c18
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

public class AddClusterRolesDecorator extends ResourceProvidingDecorator<KubernetesListBuilder> {

public static final String[] READ_VERBS = new String[] { "get", "list", "watch" };
public static final String[] UPDATE_VERBS = new String[] { "patch", "update" };

public static final String CREATE_VERB = "create";
public static final String PATCH_VERB = "patch";
public static final String DELETE_VERB = "delete";

public static final String[] READ_VERBS = new String[] { "get", "list", "watch" };
public static final String[] UPDATE_VERBS = new String[] { PATCH_VERB, "update" };

public static final String[] ALL_VERBS;
static {
final var verbs = new ArrayList<String>(READ_VERBS.length + UPDATE_VERBS.length + 2);
Expand Down Expand Up @@ -85,18 +87,20 @@ public void visit(KubernetesListBuilder list) {
.addToApiGroups(HasMetadata.getGroup(associatedResourceClass))
.addToResources(HasMetadata.getPlural(associatedResourceClass))
.addToVerbs(READ_VERBS);
if (Creator.class.isAssignableFrom(dependentResourceClass)) {
dependentRule.addToVerbs(CREATE_VERB);
}
if (Updater.class.isAssignableFrom(dependentResourceClass)) {
dependentRule.addToVerbs(UPDATE_VERBS);
}
if (Deleter.class.isAssignableFrom(dependentResourceClass)) {
dependentRule.addToVerbs(DELETE_VERB);
}
if (Creator.class.isAssignableFrom(dependentResourceClass)) {
dependentRule.addToVerbs(CREATE_VERB);
if (!dependentRule.getVerbs().contains(PATCH_VERB)) {
dependentRule.addToVerbs(PATCH_VERB);
}
}
clusterRoleBuilder.addToRules(dependentRule.build());
}

});

list.addToItems(clusterRoleBuilder.build());
Expand Down

0 comments on commit 94d4c18

Please sign in to comment.