Skip to content

Commit 3835837

Browse files
fix lint issues faced after the upgrade
1 parent 818e52c commit 3835837

16 files changed

Lines changed: 32 additions & 32 deletions

File tree

api/v1/clustercatalog_types_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func TestImageSourceCELValidationRules(t *testing.T) {
149149
obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&tc.spec) //nolint:gosec
150150
require.NoError(t, err)
151151
errs := validator(obj, nil)
152-
require.Equal(t, len(tc.wantErrs), len(errs), "want", tc.wantErrs, "got", errs)
152+
require.Len(t, errs, len(tc.wantErrs), "want", tc.wantErrs, "got", errs)
153153
for i := range tc.wantErrs {
154154
got := errs[i].Error()
155155
assert.Equal(t, tc.wantErrs[i], got)
@@ -242,7 +242,7 @@ func TestResolvedImageSourceCELValidation(t *testing.T) {
242242
} {
243243
t.Run(name, func(t *testing.T) {
244244
errs := validator(tc.spec.Ref, nil)
245-
require.Equal(t, len(tc.wantErrs), len(errs), "want", tc.wantErrs, "got", errs)
245+
require.Len(t, errs, len(tc.wantErrs), "want", tc.wantErrs, "got", errs)
246246
for i := range tc.wantErrs {
247247
got := errs[i].Error()
248248
assert.Equal(t, tc.wantErrs[i], got)
@@ -286,7 +286,7 @@ func TestClusterCatalogURLsCELValidation(t *testing.T) {
286286
t.Run(name, func(t *testing.T) {
287287
errs := validator(tc.urls.Base, nil)
288288
fmt.Println(errs)
289-
require.Equal(t, len(tc.wantErrs), len(errs))
289+
require.Len(t, errs, len(tc.wantErrs))
290290
for i := range tc.wantErrs {
291291
got := errs[i].Error()
292292
assert.Equal(t, tc.wantErrs[i], got)
@@ -327,7 +327,7 @@ func TestSourceCELValidation(t *testing.T) {
327327
require.NoError(t, err)
328328
errs := validator(obj, nil)
329329
fmt.Println(errs)
330-
require.Equal(t, len(tc.wantErrs), len(errs))
330+
require.Len(t, errs, len(tc.wantErrs))
331331
for i := range tc.wantErrs {
332332
got := errs[i].Error()
333333
assert.Equal(t, tc.wantErrs[i], got)
@@ -368,7 +368,7 @@ func TestResolvedSourceCELValidation(t *testing.T) {
368368
obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&tc.source) //nolint:gosec
369369
require.NoError(t, err)
370370
errs := validator(obj, nil)
371-
require.Equal(t, len(tc.wantErrs), len(errs))
371+
require.Len(t, errs, len(tc.wantErrs))
372372
for i := range tc.wantErrs {
373373
got := errs[i].Error()
374374
assert.Equal(t, tc.wantErrs[i], got)

hack/tools/crd-generator/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ func runGenerator(args ...string) {
120120
crdRaw := parser.CustomResourceDefinitions[groupKind]
121121

122122
// Inline version of "addAttribution(&crdRaw)" ...
123-
if crdRaw.ObjectMeta.Annotations == nil {
124-
crdRaw.ObjectMeta.Annotations = map[string]string{}
123+
if crdRaw.Annotations == nil {
124+
crdRaw.Annotations = map[string]string{}
125125
}
126-
crdRaw.ObjectMeta.Annotations[FeatureSetAnnotation] = channel
126+
crdRaw.Annotations[FeatureSetAnnotation] = channel
127127
if ctVer != "" {
128-
crdRaw.ObjectMeta.Annotations[VersionAnnotation] = ctVer
128+
crdRaw.Annotations[VersionAnnotation] = ctVer
129129
}
130130

131131
// Prevent the top level metadata for the CRD to be generated regardless of the intention in the arguments

internal/catalogd/controllers/core/clustercatalog_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
9595
defer l.Info("reconcile ending")
9696

9797
existingCatsrc := ocv1.ClusterCatalog{}
98-
if err := r.Client.Get(ctx, req.NamespacedName, &existingCatsrc); err != nil {
98+
if err := r.Get(ctx, req.NamespacedName, &existingCatsrc); err != nil {
9999
return ctrl.Result{}, client.IgnoreNotFound(err)
100100
}
101101

@@ -134,7 +134,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
134134
reconciledCatsrc.Finalizers = finalizers
135135

136136
if updateFinalizers {
137-
if err := r.Client.Update(ctx, reconciledCatsrc); err != nil {
137+
if err := r.Update(ctx, reconciledCatsrc); err != nil {
138138
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("error updating finalizers: %v", err))
139139
}
140140
}

internal/catalogd/storage/localdir_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func TestMetasEndpoint(t *testing.T) {
401401
require.Equal(t, tc.expectedStatusCode, resp.StatusCode)
402402
actualContent, err = io.ReadAll(resp.Body)
403403
require.NoError(t, err)
404-
require.Equal(t, "", string(actualContent)) // HEAD should not return a body
404+
require.Empty(t, string(actualContent)) // HEAD should not return a body
405405
resp.Body.Close()
406406

407407
// And make sure any other method is not allowed

internal/operator-controller/applier/helm_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func TestApply_InstallationWithPreflightPermissionsEnabled(t *testing.T) {
366366
objs, state, err := helmApplier.Apply(context.TODO(), validFS, validCE, testObjectLabels, testStorageLabels)
367367
require.Error(t, err)
368368
require.ErrorContains(t, err, "problem running preauthorization")
369-
require.Equal(t, "", state)
369+
require.Empty(t, state)
370370
require.Nil(t, objs)
371371
})
372372

@@ -395,7 +395,7 @@ func TestApply_InstallationWithPreflightPermissionsEnabled(t *testing.T) {
395395
objs, state, err := helmApplier.Apply(context.TODO(), validFS, validCE, testObjectLabels, testStorageLabels)
396396
require.Error(t, err)
397397
require.ErrorContains(t, err, errMissingRBAC)
398-
require.Equal(t, "", state)
398+
require.Empty(t, state)
399399
require.Nil(t, objs)
400400
})
401401

internal/operator-controller/controllers/clustercatalog_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (r *ClusterCatalogReconciler) Reconcile(ctx context.Context, req ctrl.Reque
5555
defer l.Info("reconcile ending")
5656

5757
existingCatalog := &ocv1.ClusterCatalog{}
58-
err := r.Client.Get(ctx, req.NamespacedName, existingCatalog)
58+
err := r.Get(ctx, req.NamespacedName, existingCatalog)
5959
if apierrors.IsNotFound(err) {
6060
if err := r.CatalogCache.Remove(req.Name); err != nil {
6161
return ctrl.Result{}, fmt.Errorf("error removing cache for catalog %q: %v", req.Name, err)

internal/operator-controller/controllers/clusterextension_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req
111111
defer l.Info("reconcile ending")
112112

113113
existingExt := &ocv1.ClusterExtension{}
114-
if err := r.Client.Get(ctx, req.NamespacedName, existingExt); err != nil {
114+
if err := r.Get(ctx, req.NamespacedName, existingExt); err != nil {
115115
return ctrl.Result{}, client.IgnoreNotFound(err)
116116
}
117117

@@ -141,7 +141,7 @@ func (r *ClusterExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Req
141141
reconciledExt.Finalizers = finalizers
142142

143143
if updateFinalizers {
144-
if err := r.Client.Update(ctx, reconciledExt); err != nil {
144+
if err := r.Update(ctx, reconciledExt); err != nil {
145145
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("error updating finalizers: %v", err))
146146
}
147147
}

internal/operator-controller/controllers/clusterextension_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ func TestSetDeprecationStatus(t *testing.T) {
14421442
controllers.SetDeprecationStatus(tc.clusterExtension, tc.bundle.Name, tc.deprecation)
14431443
// TODO: we should test for unexpected changes to lastTransitionTime. We only expect
14441444
// lastTransitionTime to change when the status of the condition changes.
1445-
assert.Equal(t, "", cmp.Diff(tc.expectedClusterExtension, tc.clusterExtension, cmpopts.IgnoreFields(metav1.Condition{}, "Message", "LastTransitionTime")))
1445+
assert.Empty(t, cmp.Diff(tc.expectedClusterExtension, tc.clusterExtension, cmpopts.IgnoreFields(metav1.Condition{}, "Message", "LastTransitionTime")))
14461446
})
14471447
}
14481448
}

internal/operator-controller/resolve/catalog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ func (w staticCatalogWalker) WalkCatalogs(ctx context.Context, _ string, f Catal
618618
for _, opt := range opts {
619619
opt.ApplyToList(&options)
620620
}
621-
if !options.LabelSelector.Matches(labels.Set(cat.ObjectMeta.Labels)) {
621+
if !options.LabelSelector.Matches(labels.Set(cat.Labels)) {
622622
continue
623623
}
624624
fbc, catCfg, fbcErr := v()

internal/operator-controller/rukpak/preflights/crdupgradesafety/crdupgradesafety_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestInstall(t *testing.T) {
199199
err := preflight.Install(context.Background(), tc.release)
200200
if len(tc.wantErrMsgs) != 0 {
201201
for _, expectedErrMsg := range tc.wantErrMsgs {
202-
require.ErrorContainsf(t, err, expectedErrMsg, "")
202+
require.ErrorContains(t, err, expectedErrMsg)
203203
}
204204
} else {
205205
require.NoError(t, err)
@@ -355,7 +355,7 @@ func TestUpgrade(t *testing.T) {
355355
err := preflight.Upgrade(context.Background(), tc.release)
356356
if len(tc.wantErrMsgs) != 0 {
357357
for _, expectedErrMsg := range tc.wantErrMsgs {
358-
require.ErrorContainsf(t, err, expectedErrMsg, "")
358+
require.ErrorContains(t, err, expectedErrMsg)
359359
}
360360
} else {
361361
require.NoError(t, err)

0 commit comments

Comments
 (0)