File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
staging/src/k8s.io/kubectl/pkg/util/rbac Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ go_library(
6
6
importmap = "k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/util/rbac" ,
7
7
importpath = "k8s.io/kubectl/pkg/util/rbac" ,
8
8
visibility = ["//visibility:public" ],
9
- deps = ["//staging/src/k8s.io/api/rbac/v1:go_default_library" ],
9
+ deps = [
10
+ "//staging/src/k8s.io/api/rbac/v1:go_default_library" ,
11
+ "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library" ,
12
+ ],
10
13
)
11
14
12
15
filegroup (
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package rbac
18
18
19
19
import (
20
20
rbacv1 "k8s.io/api/rbac/v1"
21
+ "k8s.io/apimachinery/pkg/util/sets"
21
22
"reflect"
22
23
"strings"
23
24
)
@@ -42,7 +43,13 @@ func CompactRules(rules []rbacv1.PolicyRule) ([]rbacv1.PolicyRule, error) {
42
43
if existingRule .Verbs == nil {
43
44
existingRule .Verbs = []string {}
44
45
}
45
- existingRule .Verbs = append (existingRule .Verbs , rule .Verbs ... )
46
+ existingVerbs := sets .NewString (existingRule .Verbs ... )
47
+ for _ , verb := range rule .Verbs {
48
+ if ! existingVerbs .Has (verb ) {
49
+ existingRule .Verbs = append (existingRule .Verbs , verb )
50
+ }
51
+ }
52
+
46
53
} else {
47
54
// Copy the rule to accumulate matching simple resource rules into
48
55
simpleRules [resource ] = rule .DeepCopy ()
You can’t perform that action at this time.
0 commit comments