Skip to content

Commit b845d03

Browse files
committed
resolve TODO about handling subresources
1 parent 21d9068 commit b845d03

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/e2e/authorization_utils.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e
22

33
import (
44
"context"
5+
"strings"
56

67
authv1 "k8s.io/api/authorization/v1"
78
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -149,8 +150,21 @@ func (t *testCase) expandResourceAttributes() []authv1.ResourceAttributes {
149150
for _, resource := range t.data.resources {
150151
for _, ra := range ras {
151152
copy := ra
152-
// TODO: handle group/resource/subresource combination
153-
copy.Resource = resource
153+
// split the resource string to get the group, resource and subresource
154+
parts := strings.Split(resource, "/")
155+
if len(parts) > 1 {
156+
switch len(parts) {
157+
case 2:
158+
copy.Group = parts[0]
159+
copy.Resource = parts[1]
160+
case 3:
161+
copy.Group = parts[0]
162+
copy.Resource = parts[1]
163+
copy.Subresource = parts[2]
164+
}
165+
} else {
166+
copy.Resource = parts[0]
167+
}
154168
resourceExpansions = append(resourceExpansions, copy)
155169
}
156170
}

0 commit comments

Comments
 (0)