Skip to content

Commit 38af679

Browse files
committed
Simplify RBAC policy rule cloning
1 parent 4d56305 commit 38af679

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

pkg/kubernetes/rbac/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313

1414
// ClonePolicyRules returns an independent copy of policy rules templates.
1515
func ClonePolicyRules(rules []rbacv1.PolicyRule) []rbacv1.PolicyRule {
16-
cloned := make([]rbacv1.PolicyRule, 0, len(rules))
17-
for _, rule := range rules {
18-
cloned = append(cloned, ClonePolicyRule(rule))
16+
cloned := slices.Clone(rules)
17+
for i := range cloned {
18+
cloned[i] = ClonePolicyRule(cloned[i])
1919
}
2020
return cloned
2121
}

0 commit comments

Comments
 (0)