Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/gateway/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func createRootCommand() *cobra.Command {
Use: "gateway",
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func createStaticModeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "static-mode",
Short: "Configure NGINX in the scope of a single Gateway resource",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
atom := zap.NewAtomicLevel()

logger := ctlrZap.New(ctlrZap.Level(atom))
Expand Down Expand Up @@ -301,7 +301,7 @@ func createProvisionerModeCommand() *cobra.Command {
Use: "provisioner-mode",
Short: "Provision a static-mode NGINX Gateway Fabric Deployment per Gateway resource",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
logger := ctlrZap.New()
logger.Info(
"Starting NGINX Gateway Fabric Provisioner",
Expand Down Expand Up @@ -348,7 +348,7 @@ func createSleepCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "sleep",
Short: "Sleep for specified duration and exit",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// It is expected that this command is run from lifecycle hook.
// Because logs from hooks are not visible in the container logs, we don't log here at all.
time.Sleep(duration)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func testFlag(t *testing.T, cmd *cobra.Command, test flagTestCase) {
cmd.SetErr(io.Discard)

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

Expand Down
8 changes: 4 additions & 4 deletions internal/framework/controller/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ var _ = Describe("Reconciler", func() {

getReturnsHRForHR := func(hr *v1.HTTPRoute) getFunc {
return func(
ctx context.Context,
_ context.Context,
nsname types.NamespacedName,
object client.Object,
option ...client.GetOption,
_ ...client.GetOption,
) error {
Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{}))
Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr)))
Expand All @@ -75,10 +75,10 @@ var _ = Describe("Reconciler", func() {

getReturnsNotFoundErrorForHR := func(hr *v1.HTTPRoute) getFunc {
return func(
ctx context.Context,
_ context.Context,
nsname types.NamespacedName,
object client.Object,
option ...client.GetOption,
_ ...client.GetOption,
) error {
Expect(object).To(BeAssignableToTypeOf(&v1.HTTPRoute{}))
Expect(nsname).To(Equal(client.ObjectKeyFromObject(hr)))
Expand Down
4 changes: 2 additions & 2 deletions internal/framework/controller/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
v1 "sigs.k8s.io/gateway-api/apis/v1"
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller"
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/controllerfakes"
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestRegister(t *testing.T) {
},
}

nsNameFilter := func(nsname types.NamespacedName) (bool, string) {
nsNameFilter := func(_ types.NamespacedName) (bool, string) {
return true, ""
}

Expand Down
12 changes: 6 additions & 6 deletions internal/framework/events/first_eventbatch_preparer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {

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

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

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

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

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

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

switch typedList := list.(type) {
Expand Down Expand Up @@ -106,7 +106,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
BeforeEach(func() {
fakeReader.GetReturns(apierrors.NewNotFound(schema.GroupResource{}, "test"))
fakeReader.ListCalls(
func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error {
func(_ context.Context, list client.ObjectList, _ ...client.ListOption) error {
httpRoute := v1.HTTPRoute{ObjectMeta: metav1.ObjectMeta{Name: "test"}}
typedList := list.(*v1.HTTPRouteList)
typedList.Items = append(typedList.Items, httpRoute)
Expand All @@ -117,7 +117,7 @@ var _ = Describe("FirstEventBatchPreparer", func() {
})

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

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

preparer.SetEachListItem(func(obj runtime.Object, fn func(runtime.Object) error) error {
preparer.SetEachListItem(func(_ runtime.Object, _ func(runtime.Object) error) error {
return testError
})

Expand Down
2 changes: 1 addition & 1 deletion internal/framework/events/loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("EventLoop", func() {

// The func below will pause the handler goroutine while it is processing the batch with e1 until
// sentSecondAndThirdEvents is closed. This way we can add e2 and e3 to the current batch in the meantime.
fakeHandler.HandleEventBatchCalls(func(ctx context.Context, logger logr.Logger, batch events.EventBatch) {
fakeHandler.HandleEventBatchCalls(func(_ context.Context, _ logr.Logger, _ events.EventBatch) {
close(firstHandleEventBatchCallInProgress)
<-sentSecondAndThirdEvents
})
Expand Down
2 changes: 1 addition & 1 deletion internal/framework/runnables/cronjob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestCronJob_ContextCanceled(t *testing.T) {
readyChannel := make(chan struct{})

cfg := CronJobConfig{
Worker: func(ctx context.Context) {},
Worker: func(_ context.Context) {},
Logger: zap.New(),
Period: 1 * time.Millisecond, // 1ms is much smaller than timeout so the CronJob should run a few times
ReadyCh: readyChannel,
Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/config_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestUpdateControlPlane(t *testing.T) {
g := NewWithT(t)

fakeLogSetter := &staticfakes.FakeLogLevelSetter{
SetLevelStub: func(s string) error {
SetLevelStub: func(_ string) error {
return test.setLevelErr
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/nginx/config/servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,6 @@ func TestCreateServersConflicts(t *testing.T) {
}

func TestCreateLocationsRootPath(t *testing.T) {
g := NewWithT(t)

hrNsName := types.NamespacedName{Namespace: "test", Name: "route1"}

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

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
g := NewGomegaWithT(t)

locs := createLocations(test.pathRules, 80)
g.Expect(locs).To(Equal(test.expLocations))
})
Expand Down
6 changes: 3 additions & 3 deletions internal/mode/static/nginx/file/folders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func TestClearFoldersFails(t *testing.T) {
}{
{
fileMgr: &filefakes.FakeClearFoldersOSFileManager{
ReadDirStub: func(dirname string) ([]os.DirEntry, error) {
ReadDirStub: func(_ string) ([]os.DirEntry, error) {
return nil, testErr
},
},
name: "ReadDir fails",
},
{
fileMgr: &filefakes.FakeClearFoldersOSFileManager{
ReadDirStub: func(dirname string) ([]os.DirEntry, error) {
ReadDirStub: func(_ string) ([]os.DirEntry, error) {
return []os.DirEntry{
&filefakes.FakeDirEntry{
NameStub: func() string {
Expand All @@ -68,7 +68,7 @@ func TestClearFoldersFails(t *testing.T) {
},
}, nil
},
RemoveStub: func(name string) error {
RemoveStub: func(_ string) error {
return testErr
},
},
Expand Down
8 changes: 4 additions & 4 deletions internal/mode/static/nginx/file/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,31 +191,31 @@ var _ = Describe("EventHandler", func() {
Entry(
"Remove",
&filefakes.FakeOSFileManager{
RemoveStub: func(s string) error {
RemoveStub: func(_ string) error {
return testErr
},
},
),
Entry(
"Create",
&filefakes.FakeOSFileManager{
CreateStub: func(s string) (*os.File, error) {
CreateStub: func(_ string) (*os.File, error) {
return nil, testErr
},
},
),
Entry(
"Chmod",
&filefakes.FakeOSFileManager{
ChmodStub: func(os *os.File, mode os.FileMode) error {
ChmodStub: func(_ *os.File, _ os.FileMode) error {
return testErr
},
},
),
Entry(
"Write",
&filefakes.FakeOSFileManager{
WriteStub: func(os *os.File, bytes []byte) error {
WriteStub: func(_ *os.File, _ []byte) error {
return testErr
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/nginx/runtime/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func findMainProcess(
ctx,
500*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
func(_ context.Context) (bool, error) {
_, err := checkFile(pidFile)
if err == nil {
return true, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/nginx/runtime/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *verifyClient) ensureConfigVersion(ctx context.Context, expectedVersion
ctx,
25*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
func(_ context.Context) (bool, error) {
version, err := c.getConfigVersion()
return version == expectedVersion, err
},
Expand All @@ -127,7 +127,7 @@ func ensureNewNginxWorkers(
ctx,
25*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
func(_ context.Context) (bool, error) {
content, err := readFile(childProcFile)
if err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/state/changed_predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

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

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

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

p := funcPredicate{stateChanged: alwaysTrueFunc}

Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/state/dataplane/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1994,9 +1994,9 @@ func TestBuildUpstreams(t *testing.T) {

fakeResolver := &resolverfakes.FakeServiceResolver{}
fakeResolver.ResolveCalls(func(
ctx context.Context,
_ context.Context,
svcNsName types.NamespacedName,
servicePort apiv1.ServicePort,
_ apiv1.ServicePort,
) ([]resolver.Endpoint, error) {
switch svcNsName.Name {
case "bar":
Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func createListCallsFunc(nodes []v1.Node) func(
list client.ObjectList,
option ...client.ListOption,
) error {
return func(ctx context.Context, list client.ObjectList, option ...client.ListOption) error {
return func(_ context.Context, list client.ObjectList, option ...client.ListOption) error {
Expect(option).To(BeEmpty())

switch typedList := list.(type) {
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func RunLoadTest(cfg LoadTestConfig) (vegeta.Results, Metrics) {
httpClient := http.Client{
Timeout: vegeta.DefaultTimeout,
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
DialContext: func(ctx context.Context, network, _ string) (net.Conn, error) {
return dialer.DialContext(ctx, network, cfg.Proxy)
},
TLSClientConfig: &tls.Config{
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ var _ = Describe("Upgrade testing", Label("upgrade"), func() {
leaseCtx,
500*time.Millisecond,
true, /* poll immediately */
func(ctx context.Context) (bool, error) {
func(_ context.Context) (bool, error) {
Expect(k8sClient.Get(leaseCtx, key, &lease)).To(Succeed())

if lease.Spec.HolderIdentity != nil {
Expand Down