Skip to content

Commit 4290449

Browse files
bentitotrgeiger
authored andcommitted
Fix linter errors
Signed-off-by: Brett Tofel <[email protected]>
1 parent 88996a3 commit 4290449

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

internal/operator-controller/applier/helm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818
corev1 "k8s.io/api/core/v1"
1919
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2020
apimachyaml "k8s.io/apimachinery/pkg/util/yaml"
21+
authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1"
2122
"k8s.io/client-go/rest"
2223
"sigs.k8s.io/controller-runtime/pkg/client"
2324
"sigs.k8s.io/controller-runtime/pkg/log"
2425

2526
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
26-
authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1"
2727

2828
ocv1 "github.com/operator-framework/operator-controller/api/v1"
2929
"github.com/operator-framework/operator-controller/internal/operator-controller/authorization"
@@ -111,7 +111,6 @@ func shouldSkipPreflight(ctx context.Context, preflight Preflight, ext *ocv1.Clu
111111
}
112112

113113
func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1.ClusterExtension, objectLabels map[string]string, storageLabels map[string]string) ([]client.Object, string, error) {
114-
115114
if features.OperatorControllerFeatureGate.Enabled(features.PreflightPermissions) {
116115
authclient, err := h.AuthClientMapper.GetAuthenticationClient(ctx, ext)
117116
if err != nil {

internal/operator-controller/authorization/authorization.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1819
const (
@@ -21,13 +22,13 @@ const (
2122
)
2223

2324
func 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

Comments
 (0)