Skip to content

Commit

Permalink
Handling Identical Kubebuilder Annotations in Different CRs with * Verbs
Browse files Browse the repository at this point in the history
Signed-off-by: Oded Viner <oviner@redhat.com>
  • Loading branch information
OdedViner committed Oct 27, 2024
1 parent 5ea1855 commit 8800e58
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/rbac/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ func GenerateRoles(ctx *genall.GenerationContext, roleName string) ([]interface{
var objs []interface{}
for _, ns := range namespaces {
rules := rulesByNSResource[ns]
for _, rule := range rules {
if containsAsterisk(rule.Verbs) {
rule.Verbs = []string{"*"}
}
}
policyRules := NormalizeRules(rules)
if len(policyRules) == 0 {
continue
Expand Down Expand Up @@ -355,6 +360,15 @@ func GenerateRoles(ctx *genall.GenerationContext, roleName string) ([]interface{
return objs, nil
}

func containsAsterisk(strList []string) bool {
for _, str := range strList {
if str == "*" {
return true
}
}
return false
}

func (g Generator) Generate(ctx *genall.GenerationContext) error {
objs, err := GenerateRoles(ctx, g.RoleName)
if err != nil {
Expand Down

0 comments on commit 8800e58

Please # to comment.