Skip to content
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 @@ -138,6 +138,12 @@ func getRBACPolicyRules(collectorOpts collectorOptions) []rbacv1.PolicyRule {
if len(collectorOpts.customResources) > 0 {
rbacBuilder := utils.NewRBACBuilder(commonVerbs...)
for _, cr := range collectorOpts.customResources {
// Don't pluralize if the kind is a wildcard
if cr.GroupVersionKind.Kind == "*" {
rbacBuilder.AddGroupKind(cr.GroupVersionKind.Group, "*")
continue
}

// Use the resource plural if specified, otherwise derive it from the Kind
resourceName := cr.ResourcePlural
if resourceName == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,31 @@ func TestGetRBACPolicyRules(t *testing.T) {
assert.True(t, hasArgo, "Should have Argo Application permissions")
},
},
{
name: "with wildcard kind",
collectorOpts: collectorOptions{
customResources: []v2alpha1.Resource{
{
GroupVersionKind: v2alpha1.GroupVersionKind{
Group: "stable.example.com",
Version: "v1",
Kind: "*",
},
},
},
},
validateFunc: func(t *testing.T, rules []rbacv1.PolicyRule) {
hasStable := false
for _, rule := range rules {
if slices.Contains(rule.APIGroups, "stable.example.com") {
hasStable = true
assert.Contains(t, rule.Resources, "*")
break
}
}
assert.True(t, hasStable, "Should have stable.example.com permissions")
},
},
}

for _, tc := range testCases {
Expand Down
Loading