Skip to content

Commit eb8624f

Browse files
authored
Fix lint issues (#1558)
Problem: Linter got updated and caught a bunch of issues. Solution: Fixed lint issues.
1 parent fde7eda commit eb8624f

18 files changed

+39
-39
lines changed

cmd/gateway/commands.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func createRootCommand() *cobra.Command {
3333
Use: "gateway",
3434
SilenceUsage: true,
3535
SilenceErrors: true,
36-
RunE: func(cmd *cobra.Command, args []string) error {
36+
RunE: func(cmd *cobra.Command, _ []string) error {
3737
return cmd.Help()
3838
},
3939
}
@@ -100,7 +100,7 @@ func createStaticModeCommand() *cobra.Command {
100100
cmd := &cobra.Command{
101101
Use: "static-mode",
102102
Short: "Configure NGINX in the scope of a single Gateway resource",
103-
RunE: func(cmd *cobra.Command, args []string) error {
103+
RunE: func(cmd *cobra.Command, _ []string) error {
104104
atom := zap.NewAtomicLevel()
105105

106106
logger := ctlrZap.New(ctlrZap.Level(atom))
@@ -301,7 +301,7 @@ func createProvisionerModeCommand() *cobra.Command {
301301
Use: "provisioner-mode",
302302
Short: "Provision a static-mode NGINX Gateway Fabric Deployment per Gateway resource",
303303
Hidden: true,
304-
RunE: func(cmd *cobra.Command, args []string) error {
304+
RunE: func(_ *cobra.Command, _ []string) error {
305305
logger := ctlrZap.New()
306306
logger.Info(
307307
"Starting NGINX Gateway Fabric Provisioner",
@@ -348,7 +348,7 @@ func createSleepCommand() *cobra.Command {
348348
cmd := &cobra.Command{
349349
Use: "sleep",
350350
Short: "Sleep for specified duration and exit",
351-
Run: func(cmd *cobra.Command, args []string) {
351+
Run: func(_ *cobra.Command, _ []string) {
352352
// It is expected that this command is run from lifecycle hook.
353353
// Because logs from hooks are not visible in the container logs, we don't log here at all.
354354
time.Sleep(duration)

cmd/gateway/commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func testFlag(t *testing.T, cmd *cobra.Command, test flagTestCase) {
2222
cmd.SetErr(io.Discard)
2323

2424
// override RunE to avoid executing the command
25-
cmd.RunE = func(cmd *cobra.Command, args []string) error {
25+
cmd.RunE = func(_ *cobra.Command, _ []string) error {
2626
return nil
2727
}
2828

internal/framework/controller/reconciler_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ var _ = Describe("Reconciler", func() {
5959

6060
getReturnsHRForHR := func(hr *v1.HTTPRoute) getFunc {
6161
return func(
62-
ctx context.Context,
62+
_ context.Context,
6363
nsname types.NamespacedName,
6464
object client.Object,
65-
option ...client.GetOption,
65+
_ ...client.GetOption,
6666
) error {
6767
Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{}))
6868
Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr)))
@@ -75,10 +75,10 @@ var _ = Describe("Reconciler", func() {
7575

7676
getReturnsNotFoundErrorForHR := func(hr *v1.HTTPRoute) getFunc {
7777
return func(
78-
ctx context.Context,
78+
_ context.Context,
7979
nsname types.NamespacedName,
8080
object client.Object,
81-
option ...client.GetOption,
81+
_ ...client.GetOption,
8282
) error {
8383
Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{}))
8484
Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr)))

internal/framework/controller/register_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"sigs.k8s.io/controller-runtime/pkg/client/fake"
1818
"sigs.k8s.io/controller-runtime/pkg/log/zap"
1919
v1 "sigs.k8s.io/gateway-api/apis/v1"
20-
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
20+
"sigs.k8s.io/gateway-api/apis/v1beta1"
2121

2222
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller"
2323
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/controllerfakes"
@@ -103,7 +103,7 @@ func TestRegister(t *testing.T) {
103103
},
104104
}
105105

106-
nsNameFilter := func(nsname types.NamespacedName) (bool, string) {
106+
nsNameFilter := func(_ types.NamespacedName) (bool, string) {
107107
return true, ""
108108
}
109109

internal/framework/events/first_eventbatch_preparer_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
4646

4747
It("should prepare zero events when resources don't exist", func() {
4848
fakeReader.GetCalls(
49-
func(ctx context.Context, name types.NamespacedName, object client.Object, opts ...client.GetOption) error {
49+
func(_ context.Context, name types.NamespacedName, object client.Object, _ ...client.GetOption) error {
5050
Expect(name).Should(Equal(types.NamespacedName{Name: gcName}))
5151
Expect(object).Should(BeAssignableToTypeOf(&v1.GatewayClass{}))
5252

@@ -65,7 +65,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
6565
gatewayClass := v1.GatewayClass{ObjectMeta: metav1.ObjectMeta{Name: gcName}}
6666

6767
fakeReader.GetCalls(
68-
func(ctx context.Context, name types.NamespacedName, object client.Object, opts ...client.GetOption) error {
68+
func(_ context.Context, name types.NamespacedName, object client.Object, _ ...client.GetOption) error {
6969
Expect(name).Should(Equal(types.NamespacedName{Name: gcName}))
7070
Expect(object).Should(BeAssignableToTypeOf(&v1.GatewayClass{}))
7171

@@ -76,7 +76,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
7676

7777
httpRoute := v1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}}
7878

79-
fakeReader.ListCalls(func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error {
79+
fakeReader.ListCalls(func(_ context.Context, list client.ObjectList, option ...client.ListOption) error {
8080
Expect(option).To(BeEmpty())
8181

8282
switch typedList := list.(type) {
@@ -106,7 +106,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
106106
BeforeEach(func() {
107107
fakeReader.GetReturns(apierrors.NewNotFound(schema.GroupResource{}, "test"))
108108
fakeReader.ListCalls(
109-
func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error {
109+
func(_ context.Context, list client.ObjectList, _ ...client.ListOption) error {
110110
httpRoute := v1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}}
111111
typedList := list.(*v1.HTTPRouteList)
112112
typedList.Items = append(typedList.Items, httpRoute)
@@ -117,7 +117,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
117117
})
118118

119119
It("should return error if EachListItem passes a wrong object type", func() {
120-
preparer.SetEachListItem(func(obj runtime.Object, fn func(runtime.Object) error) error {
120+
preparer.SetEachListItem(func(_ runtime.Object, fn func(runtime.Object) error) error {
121121
return fn(&fakeRuntimeObject{})
122122
})
123123

@@ -129,7 +129,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
129129
It("should return error if EachListItem returns an error", func() {
130130
testError := errors.New("test")
131131

132-
preparer.SetEachListItem(func(obj runtime.Object, fn func(runtime.Object) error) error {
132+
preparer.SetEachListItem(func(_ runtime.Object, _ func(runtime.Object) error) error {
133133
return testError
134134
})
135135

internal/framework/events/loop_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var _ = Describe("EventLoop", func() {
8383

8484
// The func below will pause the handler goroutine while it is processing the batch with e1 until
8585
// sentSecondAndThirdEvents is closed. This way we can add e2 and e3 to the current batch in the meantime.
86-
fakeHandler.HandleEventBatchCalls(func(ctx context.Context, logger logr.Logger, batch events.EventBatch) {
86+
fakeHandler.HandleEventBatchCalls(func(_ context.Context, _ logr.Logger, _ events.EventBatch) {
8787
close(firstHandleEventBatchCallInProgress)
8888
<-sentSecondAndThirdEvents
8989
})

internal/framework/runnables/cronjob_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestCronJob_ContextCanceled(t *testing.T) {
5555
readyChannel := make(chan struct{})
5656

5757
cfg := CronJobConfig{
58-
Worker: func(ctx context.Context) {},
58+
Worker: func(_ context.Context) {},
5959
Logger: zap.New(),
6060
Period: 1 * time.Millisecond, // 1ms is much smaller than timeout so the CronJob should run a few times
6161
ReadyCh: readyChannel,

internal/mode/static/config_updater_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestUpdateControlPlane(t *testing.T) {
7575
g := NewWithT(t)
7676

7777
fakeLogSetter := &staticfakes.FakeLogLevelSetter{
78-
SetLevelStub: func(s string) error {
78+
SetLevelStub: func(_ string) error {
7979
return test.setLevelErr
8080
},
8181
}

internal/mode/static/nginx/config/servers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,6 @@ func TestCreateServersConflicts(t *testing.T) {
987987
}
988988

989989
func TestCreateLocationsRootPath(t *testing.T) {
990-
g := NewWithT(t)
991-
992990
hrNsName := types.NamespacedName{Namespace: "test", Name: "route1"}
993991

994992
fooGroup := dataplane.BackendGroup{
@@ -1104,6 +1102,8 @@ func TestCreateLocationsRootPath(t *testing.T) {
11041102

11051103
for _, test := range tests {
11061104
t.Run(test.name, func(t *testing.T) {
1105+
g := NewWithT(t)
1106+
11071107
locs := createLocations(test.pathRules, 80)
11081108
g.Expect(locs).To(Equal(test.expLocations))
11091109
})

internal/mode/static/nginx/file/folders_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ func TestClearFoldersFails(t *testing.T) {
5151
}{
5252
{
5353
fileMgr: &filefakes.FakeClearFoldersOSFileManager{
54-
ReadDirStub: func(dirname string) ([]os.DirEntry, error) {
54+
ReadDirStub: func(_ string) ([]os.DirEntry, error) {
5555
return nil, testErr
5656
},
5757
},
5858
name: "ReadDir fails",
5959
},
6060
{
6161
fileMgr: &filefakes.FakeClearFoldersOSFileManager{
62-
ReadDirStub: func(dirname string) ([]os.DirEntry, error) {
62+
ReadDirStub: func(_ string) ([]os.DirEntry, error) {
6363
return []os.DirEntry{
6464
&filefakes.FakeDirEntry{
6565
NameStub: func() string {
@@ -68,7 +68,7 @@ func TestClearFoldersFails(t *testing.T) {
6868
},
6969
}, nil
7070
},
71-
RemoveStub: func(name string) error {
71+
RemoveStub: func(_ string) error {
7272
return testErr
7373
},
7474
},

internal/mode/static/nginx/file/manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,31 @@ var _ = Describe("EventHandler", func() {
191191
Entry(
192192
"Remove",
193193
&filefakes.FakeOSFileManager{
194-
RemoveStub: func(s string) error {
194+
RemoveStub: func(_ string) error {
195195
return testErr
196196
},
197197
},
198198
),
199199
Entry(
200200
"Create",
201201
&filefakes.FakeOSFileManager{
202-
CreateStub: func(s string) (*os.File, error) {
202+
CreateStub: func(_ string) (*os.File, error) {
203203
return nil, testErr
204204
},
205205
},
206206
),
207207
Entry(
208208
"Chmod",
209209
&filefakes.FakeOSFileManager{
210-
ChmodStub: func(os *os.File, mode os.FileMode) error {
210+
ChmodStub: func(_ *os.File, _ os.FileMode) error {
211211
return testErr
212212
},
213213
},
214214
),
215215
Entry(
216216
"Write",
217217
&filefakes.FakeOSFileManager{
218-
WriteStub: func(os *os.File, bytes []byte) error {
218+
WriteStub: func(_ *os.File, _ []byte) error {
219219
return testErr
220220
},
221221
},

internal/mode/static/nginx/runtime/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func findMainProcess(
172172
ctx,
173173
500*time.Millisecond,
174174
true, /* poll immediately */
175-
func(ctx context.Context) (bool, error) {
175+
func(_ context.Context) (bool, error) {
176176
_, err := checkFile(pidFile)
177177
if err == nil {
178178
return true, nil

internal/mode/static/nginx/runtime/verify.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (c *verifyClient) ensureConfigVersion(ctx context.Context, expectedVersion
110110
ctx,
111111
25*time.Millisecond,
112112
true, /* poll immediately */
113-
func(ctx context.Context) (bool, error) {
113+
func(_ context.Context) (bool, error) {
114114
version, err := c.getConfigVersion()
115115
return version == expectedVersion, err
116116
},
@@ -127,7 +127,7 @@ func ensureNewNginxWorkers(
127127
ctx,
128128
25*time.Millisecond,
129129
true, /* poll immediately */
130-
func(ctx context.Context) (bool, error) {
130+
func(_ context.Context) (bool, error) {
131131
content, err := readFile(childProcFile)
132132
if err != nil {
133133
return false, err

internal/mode/static/state/changed_predicate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func TestFuncPredicate(t *testing.T) {
14-
alwaysTrueFunc := func(object client.Object, _ types.NamespacedName) bool { return true }
14+
alwaysTrueFunc := func(_ client.Object, _ types.NamespacedName) bool { return true }
1515
emptyObject := &v1.Pod{}
1616

1717
p := funcPredicate{stateChanged: alwaysTrueFunc}
@@ -23,7 +23,7 @@ func TestFuncPredicate(t *testing.T) {
2323
}
2424

2525
func TestFuncPredicate_Panic(t *testing.T) {
26-
alwaysTrueFunc := func(object client.Object, _ types.NamespacedName) bool { return true }
26+
alwaysTrueFunc := func(_ client.Object, _ types.NamespacedName) bool { return true }
2727

2828
p := funcPredicate{stateChanged: alwaysTrueFunc}
2929

internal/mode/static/state/dataplane/configuration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,9 +1994,9 @@ func TestBuildUpstreams(t *testing.T) {
19941994

19951995
fakeResolver := &resolverfakes.FakeServiceResolver{}
19961996
fakeResolver.ResolveCalls(func(
1997-
ctx context.Context,
1997+
_ context.Context,
19981998
svcNsName types.NamespacedName,
1999-
servicePort apiv1.ServicePort,
1999+
_ apiv1.ServicePort,
20002000
) ([]resolver.Endpoint, error) {
20012001
switch svcNsName.Name {
20022002
case "bar":

internal/mode/static/telemetry/collector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func createListCallsFunc(nodes []v1.Node) func(
2626
list client.ObjectList,
2727
option ...client.ListOption,
2828
) error {
29-
return func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error {
29+
return func(_ context.Context, list client.ObjectList, option ...client.ListOption) error {
3030
Expect(option).To(BeEmpty())
3131

3232
switch typedList := list.(type) {

tests/framework/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func RunLoadTest(cfg LoadTestConfig) (vegeta.Results, Metrics) {
6060
httpClient := http.Client{
6161
Timeout: vegeta.DefaultTimeout,
6262
Transport: &http.Transport{
63-
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
63+
DialContext: func(ctx context.Context, network, _ string) (net.Conn, error) {
6464
return dialer.DialContext(ctx, network, cfg.Proxy)
6565
},
6666
TLSClientConfig: &tls.Config{

tests/suite/upgrade_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ var _ = Describe("Upgrade testing", Label("upgrade"), func() {
212212
leaseCtx,
213213
500*time.Millisecond,
214214
true, /* poll immediately */
215-
func(ctx context.Context) (bool, error) {
215+
func(_ context.Context) (bool, error) {
216216
Expect(k8sClient.Get(leaseCtx, key, &lease)).To(Succeed())
217217

218218
if lease.Spec.HolderIdentity != nil {

0 commit comments

Comments
 (0)