@@ -7,12 +7,13 @@ import (
77 "slices"
88 "strings"
99
10- ocv1 "github.com/operator-framework/operator-controller/api/v1"
11- authv1 "k8s.io/api/authorization/v1"
10+ authorizationv1 "k8s.io/api/authorization/v1"
1211 rbacv1 "k8s.io/api/rbac/v1"
13- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1413 authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1"
1514 "sigs.k8s.io/controller-runtime/pkg/client"
15+
16+ ocv1 "github.com/operator-framework/operator-controller/api/v1"
1617)
1718
1819const (
@@ -21,13 +22,13 @@ const (
2122)
2223
2324func CheckObjectPermissions (ctx context.Context , authcl * authorizationv1client.AuthorizationV1Client , objects []client.Object , ext * ocv1.ClusterExtension ) error {
24- ssrr := & authv1 .SelfSubjectRulesReview {
25- Spec : authv1 .SelfSubjectRulesReviewSpec {
25+ ssrr := & authorizationv1 .SelfSubjectRulesReview {
26+ Spec : authorizationv1 .SelfSubjectRulesReviewSpec {
2627 Namespace : ext .Spec .Namespace ,
2728 },
2829 }
2930
30- ssrr , err := authcl .SelfSubjectRulesReviews ().Create (ctx , ssrr , v1 .CreateOptions {})
31+ ssrr , err := authcl .SelfSubjectRulesReviews ().Create (ctx , ssrr , metav1 .CreateOptions {})
3132 if err != nil {
3233 return err
3334 }
@@ -49,14 +50,14 @@ func CheckObjectPermissions(ctx context.Context, authcl *authorizationv1client.A
4950 })
5051 }
5152
52- resAttrs := []authv1 .ResourceAttributes {}
53+ resAttrs := []authorizationv1 .ResourceAttributes {}
5354 namespacedErrs := []error {}
5455 clusterScopedErrs := []error {}
5556 requiredVerbs := []string {"get" , "create" , "update" , "list" , "watch" , "delete" , "patch" }
5657
5758 for _ , o := range objects {
5859 for _ , verb := range requiredVerbs {
59- resAttrs = append (resAttrs , authv1 .ResourceAttributes {
60+ resAttrs = append (resAttrs , authorizationv1 .ResourceAttributes {
6061 Namespace : o .GetNamespace (),
6162 Verb : verb ,
6263 Resource : sanitizeResourceName (o .GetObjectKind ().GroupVersionKind ().Kind ),
@@ -88,11 +89,10 @@ func CheckObjectPermissions(ctx context.Context, authcl *authorizationv1client.A
8889 }
8990
9091 return errors .Join (errs ... )
91-
9292}
9393
9494// Checks if the rules allow the verb on the GroupVersionKind in resAttr
95- func canI (resAttr authv1 .ResourceAttributes , rules []rbacv1.PolicyRule ) bool {
95+ func canI (resAttr authorizationv1 .ResourceAttributes , rules []rbacv1.PolicyRule ) bool {
9696 var canI bool
9797 for _ , rule := range rules {
9898 if (slices .Contains (rule .APIGroups , resAttr .Group ) || slices .Contains (rule .APIGroups , "*" )) &&
0 commit comments