Skip to content

Commit f577be9

Browse files
committed
🌱 Bump golangci-lint to v1.62.2 and fix all lint errors
Manual cherry-pick of kubernetes-sigs#5255
1 parent f4bd35e commit f577be9

31 files changed

+173
-152
lines changed

.github/workflows/pr-golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828
- name: golangci-lint
2929
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # tag=v6.0.1
3030
with:
31-
version: v1.56.1
31+
version: v1.62.2
3232
args: --out-format=colored-line-number
3333
working-directory: ${{matrix.working-directory}}

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
231231
files, err := r.resolveFiles(ctx, config)
232232
if err != nil {
233233
log.Info("Failed to resolve files for user data")
234-
conditions.MarkFalse(config, eksbootstrapv1.DataSecretAvailableCondition, eksbootstrapv1.DataSecretGenerationFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
234+
conditions.MarkFalse(config, eksbootstrapv1.DataSecretAvailableCondition, eksbootstrapv1.DataSecretGenerationFailedReason, clusterv1.ConditionSeverityWarning, "%s", err.Error())
235235
return err
236236
}
237237

bootstrap/eks/controllers/eksconfig_controller_reconciler_test.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ func TestEKSConfigReconciler(t *testing.T) {
5454
reconciler := EKSConfigReconciler{
5555
Client: testEnv.Client,
5656
}
57-
t.Logf(fmt.Sprintf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name))
57+
t.Logf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name)
5858
g.Eventually(func(gomega Gomega) {
5959
err := reconciler.joinWorker(ctx, cluster, config, configOwner("Machine"))
6060
gomega.Expect(err).NotTo(HaveOccurred())
6161
}).Should(Succeed())
6262

63-
t.Logf(fmt.Sprintf("Secret '%s' should exist and be correct", config.Name))
63+
t.Logf("Secret '%s' should exist and be correct", config.Name)
6464
secretList := &corev1.SecretList{}
6565
testEnv.Client.List(ctx, secretList)
66-
t.Logf(dump("secrets", secretList))
66+
t.Log(dump("secrets", secretList))
6767
secret := &corev1.Secret{}
6868
g.Eventually(func(gomega Gomega) {
6969
gomega.Expect(testEnv.Client.Get(ctx, client.ObjectKey{
@@ -91,10 +91,10 @@ func TestEKSConfigReconciler(t *testing.T) {
9191
},
9292
}
9393
config.Status.DataSecretName = &mp.Name
94-
t.Logf(dump("amcp", amcp))
95-
t.Logf(dump("config", config))
96-
t.Logf(dump("machinepool", mp))
97-
t.Logf(dump("cluster", cluster))
94+
t.Log(dump("amcp", amcp))
95+
t.Log(dump("config", config))
96+
t.Log(dump("machinepool", mp))
97+
t.Log(dump("cluster", cluster))
9898
oldUserData, err := newUserData(cluster.Name, map[string]string{"test-arg": "test-value"})
9999
g.Expect(err).To(BeNil())
100100
expectedUserData, err := newUserData(cluster.Name, map[string]string{"test-arg": "updated-test-value"})
@@ -103,21 +103,21 @@ func TestEKSConfigReconciler(t *testing.T) {
103103

104104
amcpList := &ekscontrolplanev1.AWSManagedControlPlaneList{}
105105
testEnv.Client.List(ctx, amcpList)
106-
t.Logf(dump("stored-amcps", amcpList))
106+
t.Log(dump("stored-amcps", amcpList))
107107

108108
reconciler := EKSConfigReconciler{
109109
Client: testEnv.Client,
110110
}
111-
t.Logf(fmt.Sprintf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name))
111+
t.Logf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name)
112112
g.Eventually(func(gomega Gomega) {
113113
err := reconciler.joinWorker(ctx, cluster, config, configOwner("MachinePool"))
114114
gomega.Expect(err).NotTo(HaveOccurred())
115115
}).Should(Succeed())
116116

117-
t.Logf(fmt.Sprintf("Secret '%s' should exist and be correct", config.Name))
117+
t.Logf("Secret '%s' should exist and be correct", config.Name)
118118
secretList := &corev1.SecretList{}
119119
testEnv.Client.List(ctx, secretList)
120-
t.Logf(dump("secrets", secretList))
120+
t.Log(dump("secrets", secretList))
121121

122122
secret := &corev1.Secret{}
123123
g.Eventually(func(gomega Gomega) {
@@ -132,15 +132,15 @@ func TestEKSConfigReconciler(t *testing.T) {
132132
config.Spec.KubeletExtraArgs = map[string]string{
133133
"test-arg": "updated-test-value",
134134
}
135-
t.Logf(dump("config", config))
135+
t.Log(dump("config", config))
136136
g.Eventually(func(gomega Gomega) {
137137
err := reconciler.joinWorker(ctx, cluster, config, configOwner("MachinePool"))
138138
gomega.Expect(err).NotTo(HaveOccurred())
139139
}).Should(Succeed())
140-
t.Logf(fmt.Sprintf("Secret '%s' should exist and be up to date", config.Name))
140+
t.Logf("Secret '%s' should exist and be up to date", config.Name)
141141

142142
testEnv.Client.List(ctx, secretList)
143-
t.Logf(dump("secrets", secretList))
143+
t.Log(dump("secrets", secretList))
144144
g.Eventually(func(gomega Gomega) {
145145
gomega.Expect(testEnv.Client.Get(ctx, client.ObjectKey{
146146
Name: config.Name,
@@ -156,10 +156,10 @@ func TestEKSConfigReconciler(t *testing.T) {
156156
cluster := newCluster(amcp.Name)
157157
machine := newMachine(cluster, "test-machine")
158158
config := newEKSConfig(machine)
159-
t.Logf(dump("amcp", amcp))
160-
t.Logf(dump("config", config))
161-
t.Logf(dump("machine", machine))
162-
t.Logf(dump("cluster", cluster))
159+
t.Log(dump("amcp", amcp))
160+
t.Log(dump("config", config))
161+
t.Log(dump("machine", machine))
162+
t.Log(dump("cluster", cluster))
163163
expectedUserData, err := newUserData(cluster.Name, map[string]string{"test-arg": "test-value"})
164164
g.Expect(err).To(BeNil())
165165
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
@@ -174,21 +174,21 @@ func TestEKSConfigReconciler(t *testing.T) {
174174

175175
amcpList := &ekscontrolplanev1.AWSManagedControlPlaneList{}
176176
testEnv.Client.List(ctx, amcpList)
177-
t.Logf(dump("stored-amcps", amcpList))
177+
t.Log(dump("stored-amcps", amcpList))
178178

179179
reconciler := EKSConfigReconciler{
180180
Client: testEnv.Client,
181181
}
182-
t.Logf(fmt.Sprintf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name))
182+
t.Logf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name)
183183
g.Eventually(func(gomega Gomega) {
184184
err := reconciler.joinWorker(ctx, cluster, config, configOwner("Machine"))
185185
gomega.Expect(err).NotTo(HaveOccurred())
186186
}).Should(Succeed())
187187

188-
t.Logf(fmt.Sprintf("Secret '%s' should exist and be out of date", config.Name))
188+
t.Logf("Secret '%s' should exist and be out of date", config.Name)
189189
secretList := &corev1.SecretList{}
190190
testEnv.Client.List(ctx, secretList)
191-
t.Logf(dump("secrets", secretList))
191+
t.Log(dump("secrets", secretList))
192192

193193
secret = &corev1.Secret{}
194194
g.Eventually(func(gomega Gomega) {
@@ -226,11 +226,11 @@ func TestEKSConfigReconciler(t *testing.T) {
226226
"secretKey": []byte(secretContent),
227227
},
228228
}
229-
t.Logf(dump("amcp", amcp))
230-
t.Logf(dump("config", config))
231-
t.Logf(dump("machine", machine))
232-
t.Logf(dump("cluster", cluster))
233-
t.Logf(dump("secret", secret))
229+
t.Log(dump("amcp", amcp))
230+
t.Log(dump("config", config))
231+
t.Log(dump("machine", machine))
232+
t.Log(dump("cluster", cluster))
233+
t.Log(dump("secret", secret))
234234
g.Expect(testEnv.Client.Create(ctx, secret)).To(Succeed())
235235
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
236236

@@ -252,15 +252,15 @@ func TestEKSConfigReconciler(t *testing.T) {
252252
reconciler := EKSConfigReconciler{
253253
Client: testEnv.Client,
254254
}
255-
t.Logf(fmt.Sprintf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name))
255+
t.Logf("Calling reconcile on cluster '%s' and config '%s' should requeue", cluster.Name, config.Name)
256256
g.Eventually(func(gomega Gomega) {
257257
err := reconciler.joinWorker(ctx, cluster, config, configOwner("Machine"))
258258
gomega.Expect(err).NotTo(HaveOccurred())
259259
}).Should(Succeed())
260260

261261
secretList := &corev1.SecretList{}
262262
testEnv.Client.List(ctx, secretList)
263-
t.Logf(dump("secrets", secretList))
263+
t.Log(dump("secrets", secretList))
264264
gotSecret := &corev1.Secret{}
265265
g.Eventually(func(gomega Gomega) {
266266
gomega.Expect(testEnv.Client.Get(ctx, client.ObjectKey{

cmd/clusterawsadm/ami/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func LatestPatchRelease(searchVersion string) (string, error) {
6767
if err != nil {
6868
return "", err
6969
}
70-
resp, err := http.Get(fmt.Sprintf(latestStableReleaseURL, "-"+strconv.Itoa(int(searchSemVer.Major))+"."+strconv.Itoa(int(searchSemVer.Minor))))
70+
resp, err := http.Get(fmt.Sprintf(latestStableReleaseURL, "-"+strconv.Itoa(int(searchSemVer.Major))+"."+strconv.Itoa(int(searchSemVer.Minor)))) //#nosec G115
7171
if err != nil {
7272
return "", err
7373
}

cmd/clusterawsadm/cloudformation/bootstrap/template_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package bootstrap
1818

1919
import (
2020
"bytes"
21-
"fmt"
2221
"os"
2322
"path"
2423
"testing"
@@ -206,7 +205,7 @@ func TestRenderCloudformation(t *testing.T) {
206205
dmp := diffmatchpatch.New()
207206
diffs := dmp.DiffMain(string(tData), string(data), false)
208207
out := dmp.DiffPrettyText(diffs)
209-
t.Fatalf(fmt.Sprintf("Differing output (%s):\n%s", c.fixture, out))
208+
t.Fatalf("Differing output (%s):\n%s", c.fixture, out)
210209
}
211210
})
212211
}

controllers/awscluster_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (r *AWSClusterReconciler) reconcileLoadBalancer(clusterScope *scope.Cluster
278278

279279
if err := elbService.ReconcileLoadbalancers(); err != nil {
280280
clusterScope.Error(err, "failed to reconcile load balancer")
281-
conditions.MarkFalse(awsCluster, infrav1.LoadBalancerReadyCondition, infrav1.LoadBalancerFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), err.Error())
281+
conditions.MarkFalse(awsCluster, infrav1.LoadBalancerReadyCondition, infrav1.LoadBalancerFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), "%s", err.Error())
282282
return nil, err
283283
}
284284

@@ -330,12 +330,12 @@ func (r *AWSClusterReconciler) reconcileNormal(clusterScope *scope.ClusterScope)
330330

331331
if err := sgService.ReconcileSecurityGroups(); err != nil {
332332
clusterScope.Error(err, "failed to reconcile security groups")
333-
conditions.MarkFalse(awsCluster, infrav1.ClusterSecurityGroupsReadyCondition, infrav1.ClusterSecurityGroupReconciliationFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), err.Error())
333+
conditions.MarkFalse(awsCluster, infrav1.ClusterSecurityGroupsReadyCondition, infrav1.ClusterSecurityGroupReconciliationFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), "%s", err.Error())
334334
return reconcile.Result{}, err
335335
}
336336

337337
if err := ec2Service.ReconcileBastion(); err != nil {
338-
conditions.MarkFalse(awsCluster, infrav1.BastionHostReadyCondition, infrav1.BastionHostFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), err.Error())
338+
conditions.MarkFalse(awsCluster, infrav1.BastionHostReadyCondition, infrav1.BastionHostFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), "%s", err.Error())
339339
clusterScope.Error(err, "failed to reconcile bastion host")
340340
return reconcile.Result{}, err
341341
}
@@ -355,7 +355,7 @@ func (r *AWSClusterReconciler) reconcileNormal(clusterScope *scope.ClusterScope)
355355
}
356356

357357
if err := s3Service.ReconcileBucket(); err != nil {
358-
conditions.MarkFalse(awsCluster, infrav1.S3BucketReadyCondition, infrav1.S3BucketFailedReason, clusterv1.ConditionSeverityError, err.Error())
358+
conditions.MarkFalse(awsCluster, infrav1.S3BucketReadyCondition, infrav1.S3BucketFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
359359
return reconcile.Result{}, errors.Wrapf(err, "failed to reconcile S3 Bucket for AWSCluster %s/%s", awsCluster.Namespace, awsCluster.Name)
360360
}
361361

controllers/awsmachine_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
335335
// all the other errors are blocking.
336336
// Because we are reconciling all load balancers, attempt to treat the error as a list of errors.
337337
if err = kerrors.FilterOut(err, elb.IsAccessDenied, elb.IsNotFound); err != nil {
338-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, err.Error())
338+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, "%s", err.Error())
339339
return ctrl.Result{}, errors.Errorf("failed to reconcile LB attachment: %+v", err)
340340
}
341341
}
@@ -374,7 +374,7 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
374374

375375
if err := ec2Service.TerminateInstance(instance.ID); err != nil {
376376
machineScope.Error(err, "failed to terminate instance")
377-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.InstanceReadyCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, err.Error())
377+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.InstanceReadyCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, "%s", err.Error())
378378
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedTerminate", "Failed to terminate instance %q: %v", instance.ID, err)
379379
return ctrl.Result{}, err
380380
}
@@ -402,7 +402,7 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
402402
for _, id := range machineScope.AWSMachine.Spec.NetworkInterfaces {
403403
if err := ec2Service.DetachSecurityGroupsFromNetworkInterface(core, id); err != nil {
404404
machineScope.Error(err, "failed to detach security groups from instance's network interfaces")
405-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.SecurityGroupsReadyCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, err.Error())
405+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.SecurityGroupsReadyCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, "%s", err.Error())
406406
return ctrl.Result{}, err
407407
}
408408
}
@@ -494,7 +494,7 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
494494
instance, err := r.findInstance(machineScope, ec2svc)
495495
if err != nil {
496496
machineScope.Error(err, "unable to find instance")
497-
conditions.MarkUnknown(machineScope.AWSMachine, infrav1.InstanceReadyCondition, infrav1.InstanceNotFoundReason, err.Error())
497+
conditions.MarkUnknown(machineScope.AWSMachine, infrav1.InstanceReadyCondition, infrav1.InstanceNotFoundReason, "%s", err.Error())
498498
return ctrl.Result{}, err
499499
}
500500

@@ -527,7 +527,7 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
527527
instance, err = r.createInstance(ec2svc, machineScope, clusterScope, objectStoreSvc)
528528
if err != nil {
529529
machineScope.Error(err, "unable to create instance")
530-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.InstanceReadyCondition, infrav1.InstanceProvisionFailedReason, clusterv1.ConditionSeverityError, err.Error())
530+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.InstanceReadyCondition, infrav1.InstanceProvisionFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
531531
return ctrl.Result{}, err
532532
}
533533
}
@@ -658,7 +658,7 @@ func (r *AWSMachineReconciler) reconcileOperationalState(ec2svc services.EC2Inte
658658
// Ensure that the security groups are correct.
659659
_, err = r.ensureSecurityGroups(ec2svc, machineScope, machineScope.AWSMachine.Spec.AdditionalSecurityGroups, existingSecurityGroups)
660660
if err != nil {
661-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.SecurityGroupsReadyCondition, infrav1.SecurityGroupsFailedReason, clusterv1.ConditionSeverityError, err.Error())
661+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.SecurityGroupsReadyCondition, infrav1.SecurityGroupsFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
662662
machineScope.Error(err, "unable to ensure security groups")
663663
return err
664664
}
@@ -987,7 +987,7 @@ func (r *AWSMachineReconciler) registerInstanceToClassicLB(machineScope *scope.M
987987
if err := elbsvc.RegisterInstanceWithAPIServerELB(i); err != nil {
988988
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
989989
"Failed to register control plane instance %q with classic load balancer: %v", i.ID, err)
990-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, err.Error())
990+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
991991
return errors.Wrapf(err, "could not register control plane instance %q with classic load balancer", i.ID)
992992
}
993993
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeNormal, "SuccessfulAttachControlPlaneELB",
@@ -1019,7 +1019,7 @@ func (r *AWSMachineReconciler) registerInstanceToV2LB(machineScope *scope.Machin
10191019
if err := elbsvc.RegisterInstanceWithAPIServerLB(instance, lb); err != nil {
10201020
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
10211021
"Failed to register control plane instance %q with load balancer: %v", instance.ID, err)
1022-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, err.Error())
1022+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
10231023
return errors.Wrapf(err, "could not register control plane instance %q with load balancer", instance.ID)
10241024
}
10251025
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeNormal, "SuccessfulAttachControlPlaneELB",
@@ -1043,7 +1043,7 @@ func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(machineScope *sco
10431043
if err := elbsvc.DeregisterInstanceFromAPIServerELB(instance); err != nil {
10441044
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10451045
"Failed to deregister control plane instance %q from load balancer: %v", instance.ID, err)
1046-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, err.Error())
1046+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
10471047
return errors.Wrapf(err, "could not deregister control plane instance %q from load balancer", instance.ID)
10481048
}
10491049

@@ -1068,7 +1068,7 @@ func (r *AWSMachineReconciler) deregisterInstanceFromV2LB(machineScope *scope.Ma
10681068
if err := elbsvc.DeregisterInstanceFromAPIServerLB(targetGroupArn, i); err != nil {
10691069
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10701070
"Failed to deregister control plane instance %q from load balancer: %v", i.ID, err)
1071-
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, err.Error())
1071+
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
10721072
return errors.Wrapf(err, "could not deregister control plane instance %q from load balancer", i.ID)
10731073
}
10741074
}

0 commit comments

Comments
 (0)