Skip to content

Commit 9bd16f3

Browse files
authored
chore: update Go code for new lints (#13437)
Before updating our dev image with a new version of golangci-lint, this change updates our Go code to satisfy new lints. No functional changes.
1 parent b3d9605 commit 9bd16f3

File tree

12 files changed

+22
-23
lines changed

12 files changed

+22
-23
lines changed

multicluster/cmd/check.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func (hc *healthChecker) checkRemoteClusterAnchors(ctx context.Context, localAnc
475475

476476
func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error {
477477
links := []string{}
478-
errors := []string{}
478+
messages := []string{}
479479
for _, link := range hc.links {
480480
err := healthcheck.CheckServiceAccounts(
481481
ctx,
@@ -485,7 +485,7 @@ func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error
485485
serviceMirrorComponentsSelector(link.TargetClusterName),
486486
)
487487
if err != nil {
488-
errors = append(errors, err.Error())
488+
messages = append(messages, err.Error())
489489
}
490490
err = healthcheck.CheckClusterRoles(
491491
ctx,
@@ -495,7 +495,7 @@ func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error
495495
serviceMirrorComponentsSelector(link.TargetClusterName),
496496
)
497497
if err != nil {
498-
errors = append(errors, err.Error())
498+
messages = append(messages, err.Error())
499499
}
500500
err = healthcheck.CheckClusterRoleBindings(
501501
ctx,
@@ -505,7 +505,7 @@ func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error
505505
serviceMirrorComponentsSelector(link.TargetClusterName),
506506
)
507507
if err != nil {
508-
errors = append(errors, err.Error())
508+
messages = append(messages, err.Error())
509509
}
510510
err = healthcheck.CheckRoles(
511511
ctx,
@@ -516,7 +516,7 @@ func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error
516516
serviceMirrorComponentsSelector(link.TargetClusterName),
517517
)
518518
if err != nil {
519-
errors = append(errors, err.Error())
519+
messages = append(messages, err.Error())
520520
}
521521
err = healthcheck.CheckRoleBindings(
522522
ctx,
@@ -527,12 +527,12 @@ func (hc *healthChecker) checkServiceMirrorLocalRBAC(ctx context.Context) error
527527
serviceMirrorComponentsSelector(link.TargetClusterName),
528528
)
529529
if err != nil {
530-
errors = append(errors, err.Error())
530+
messages = append(messages, err.Error())
531531
}
532532
links = append(links, fmt.Sprintf("\t* %s", link.TargetClusterName))
533533
}
534-
if len(errors) > 0 {
535-
return fmt.Errorf(strings.Join(errors, "\n"))
534+
if len(messages) > 0 {
535+
return errors.New(strings.Join(messages, "\n"))
536536
}
537537
if len(links) == 0 {
538538
return healthcheck.SkipError{Reason: "no links"}

pkg/healthcheck/healthcheck.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ func (hc *HealthChecker) checkMisconfiguredOpaquePortAnnotations(ctx context.Con
24032403
}
24042404

24052405
if len(errStrings) >= 1 {
2406-
return fmt.Errorf(strings.Join(errStrings, "\n "))
2406+
return errors.New(strings.Join(errStrings, "\n "))
24072407
}
24082408

24092409
return nil
@@ -2906,7 +2906,7 @@ func CheckPodsRunning(pods []corev1.Pod, namespace string) error {
29062906
if namespace != "" {
29072907
msg += fmt.Sprintf(" in the \"%s\" namespace", namespace)
29082908
}
2909-
return fmt.Errorf(msg)
2909+
return errors.New(msg)
29102910
}
29112911
for _, pod := range pods {
29122912
status := k8s.GetPodStatus(pod)

pkg/identity/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (svc *Service) Run(issuerEvent <-chan struct{}, issuerError <-chan error) {
103103
svc.recordEvent(nil, v1.EventTypeWarning, eventTypeSkipped, message)
104104
} else {
105105
message := "Updated identity issuer"
106-
log.Infof(message)
106+
log.Info(message)
107107
svc.recordEvent(nil, v1.EventTypeNormal, eventTypeUpdated, message)
108108
}
109109
case err := <-issuerError:

pkg/inject/inject.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ func (conf *ResourceConfig) injectPodSpec(values *podPatch) {
10581058

10591059
// use the primary container's capabilities to ensure psp compliance, if
10601060
// enabled
1061-
if conf.pod.spec.Containers != nil && len(conf.pod.spec.Containers) > 0 {
1061+
if len(conf.pod.spec.Containers) > 0 {
10621062
if sc := conf.pod.spec.Containers[0].SecurityContext; sc != nil && sc.Capabilities != nil {
10631063
values.Proxy.Capabilities = &l5dcharts.Capabilities{
10641064
Add: []string{},

pkg/protohttp/protohttp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestWriteErrorToHttpResponse(t *testing.T) {
187187

188188
responseWriter := newStubResponseWriter()
189189
expectedErrorMessage := "error message"
190-
grpcError := status.Errorf(codes.AlreadyExists, expectedErrorMessage)
190+
grpcError := status.Error(codes.AlreadyExists, expectedErrorMessage)
191191

192192
WriteErrorToHTTPResponse(responseWriter, grpcError)
193193

pkg/version/version_test.go

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

33
import (
44
"errors"
5-
"fmt"
65
"testing"
76
)
87

@@ -78,7 +77,7 @@ func TestMatch(t *testing.T) {
7877

7978
for _, tc := range testCases {
8079
tc := tc // pin
81-
t.Run(fmt.Sprintf(tc.name), func(t *testing.T) {
80+
t.Run(tc.name, func(t *testing.T) {
8281
err := match(tc.expected, tc.actual)
8382
if (err == nil && tc.err != nil) ||
8483
(err != nil && tc.err == nil) ||

test/integration/deep/dualstack/dualstack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestDualStack(t *testing.T) {
145145
testutil.AnnotatedFatalf(t, "unexpected error", "unexpected error: %v\noutput:\n%s", err, out)
146146
}
147147
if out != "IPv6\n" {
148-
testutil.AnnotatedFatalf(t, "expected 'IPv6', received '%s'", out)
148+
testutil.AnnotatedFatalf(t, "expected 'IPv6'", "received '%s'", out)
149149
}
150150
})
151151

@@ -162,7 +162,7 @@ func TestDualStack(t *testing.T) {
162162
testutil.AnnotatedFatalf(t, "unexpected error", "unexpected error: %v\noutput:\n%s", err, out)
163163
}
164164
if out != "IPv6\n" {
165-
testutil.AnnotatedFatalf(t, "expected 'IPv6', received '%s'", out)
165+
testutil.AnnotatedFatalf(t, "expected 'IPv6'", "received '%s'", out)
166166
}
167167
}
168168
})

test/integration/install/inject/inject_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ func TestInjectAutoParams(t *testing.T) {
183183
})
184184

185185
if err != nil {
186-
testutil.AnnotatedFatalf(t, "failed to find autoinjected pod: ", err.Error())
186+
testutil.AnnotatedFatal(t, "failed to find autoinjected pod: ", err.Error())
187187
}
188188

189189
if err := injectionValidator.ValidatePod(&pod.Spec); err != nil {
190-
testutil.AnnotatedFatalf(t, "failed to validate auto injection", err.Error())
190+
testutil.AnnotatedFatal(t, "failed to validate auto injection", err.Error())
191191
}
192192
})
193193
}

test/integration/multicluster/multicluster-traffic/pod_to_pod_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestPodToPodTraffic(t *testing.T) {
102102
testutil.AnnotatedFatal(t, "mirror service should not have endpoints", "mirror service should not have endpoints")
103103
}
104104
if !kerrors.IsNotFound(err) {
105-
testutil.AnnotatedFatalf(t, "failed to retrieve mirror service endpoints", err.Error())
105+
testutil.AnnotatedFatal(t, "failed to retrieve mirror service endpoints", err.Error())
106106
}
107107
return nil
108108
})

test/integration/viz/install_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestDashboard(t *testing.T) {
151151
output := strings.Join(outputLines, "")
152152
if !strings.Contains(output, dashboardURL) {
153153
testutil.AnnotatedFatalf(t,
154-
"dashboard command failed. Expected url [%s] not present", dashboardURL)
154+
"dashboard command failed", "Expected url [%s] not present", dashboardURL)
155155
}
156156

157157
resp, err := TestHelper.HTTPGetURL(dashboardURL + "/api/version")

0 commit comments

Comments
 (0)