diff --git a/cmd/gateway/initialize_test.go b/cmd/gateway/initialize_test.go index fcdc84990d..6f0f00ad8f 100644 --- a/cmd/gateway/initialize_test.go +++ b/cmd/gateway/initialize_test.go @@ -8,8 +8,8 @@ import ( "path/filepath" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing/licensingfakes" @@ -27,7 +27,7 @@ func TestInitialize_OSS(t *testing.T) { ic := initializeConfig{ fileManager: fakeFileMgr, - logger: zap.New(), + logger: logr.Discard(), copy: copyFiles{ destDirName: "destDir", srcFileNames: []string{"src1", "src2"}, @@ -55,7 +55,7 @@ func TestInitialize_OSS_Error(t *testing.T) { ic := initializeConfig{ fileManager: fakeFileMgr, - logger: zap.New(), + logger: logr.Discard(), copy: copyFiles{ destDirName: "destDir", srcFileNames: []string{"src1", "src2"}, @@ -111,7 +111,7 @@ func TestInitialize_Plus(t *testing.T) { ic := initializeConfig{ fileManager: fakeFileMgr, - logger: zap.New(), + logger: logr.Discard(), collector: fakeCollector, fileGenerator: fakeGenerator, copy: copyFiles{ diff --git a/internal/framework/controller/register_test.go b/internal/framework/controller/register_test.go index e4a2fbc40c..115b737737 100644 --- a/internal/framework/controller/register_test.go +++ b/internal/framework/controller/register_test.go @@ -6,6 +6,7 @@ import ( "reflect" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" "github.com/onsi/gomega/gcustom" gtypes "github.com/onsi/gomega/types" @@ -14,7 +15,6 @@ import ( "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -43,7 +43,7 @@ func TestRegister(t *testing.T) { mgr := &controllerfakes.FakeManager{} mgr.GetClientReturns(fake.NewClientBuilder().Build()) mgr.GetSchemeReturns(scheme) - mgr.GetLoggerReturns(zap.New()) + mgr.GetLoggerReturns(logr.Discard()) mgr.GetFieldIndexerReturns(indexer) return fakes{ diff --git a/internal/framework/events/events_test.go b/internal/framework/events/events_test.go index 6ed5ce8b54..12294e3d87 100644 --- a/internal/framework/events/events_test.go +++ b/internal/framework/events/events_test.go @@ -3,14 +3,14 @@ package events import ( "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" ) func TestEventLoop_SwapBatches(t *testing.T) { t.Parallel() g := NewWithT(t) - eventLoop := NewEventLoop(nil, zap.New(), nil, nil) + eventLoop := NewEventLoop(nil, logr.Discard(), nil, nil) eventLoop.currentBatch = EventBatch{ "event0", diff --git a/internal/framework/events/loop_test.go b/internal/framework/events/loop_test.go index 45560c4ce2..02f5a00b04 100644 --- a/internal/framework/events/loop_test.go +++ b/internal/framework/events/loop_test.go @@ -8,7 +8,6 @@ import ( "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/framework/events" "github.com/nginx/nginx-gateway-fabric/internal/framework/events/eventsfakes" @@ -28,7 +27,7 @@ var _ = Describe("EventLoop", func() { eventCh = make(chan interface{}) fakePreparer = &eventsfakes.FakeFirstEventBatchPreparer{} - eventLoop = events.NewEventLoop(eventCh, zap.New(), fakeHandler, fakePreparer) + eventLoop = events.NewEventLoop(eventCh, logr.Discard(), fakeHandler, fakePreparer) errorCh = make(chan error) }) diff --git a/internal/framework/runnables/cronjob_test.go b/internal/framework/runnables/cronjob_test.go index 310ceef618..81be2a8c8c 100644 --- a/internal/framework/runnables/cronjob_test.go +++ b/internal/framework/runnables/cronjob_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "github.com/go-logr/logr" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" ) func TestCronJob(t *testing.T) { @@ -26,7 +26,7 @@ func TestCronJob(t *testing.T) { cfg := CronJobConfig{ Worker: worker, - Logger: zap.New(), + Logger: logr.Discard(), Period: 1 * time.Millisecond, // 1ms is much smaller than timeout so the CronJob should run a few times ReadyCh: readyChannel, } @@ -58,7 +58,7 @@ func TestCronJob_ContextCanceled(t *testing.T) { cfg := CronJobConfig{ Worker: func(_ context.Context) {}, - Logger: zap.New(), + Logger: logr.Discard(), Period: 1 * time.Millisecond, // 1ms is much smaller than timeout so the CronJob should run a few times ReadyCh: readyChannel, } diff --git a/internal/framework/status/leader_aware_group_updater_test.go b/internal/framework/status/leader_aware_group_updater_test.go index c2bd5b702b..7f164afc05 100644 --- a/internal/framework/status/leader_aware_group_updater_test.go +++ b/internal/framework/status/leader_aware_group_updater_test.go @@ -3,13 +3,13 @@ package status import ( "context" + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -46,7 +46,7 @@ var _ = Describe("LeaderAwareGroupUpdater", func() { ) BeforeAll(func() { - updater = NewLeaderAwareGroupUpdater(NewUpdater(k8sClient, zap.New())) + updater = NewLeaderAwareGroupUpdater(NewUpdater(k8sClient, logr.Discard())) for _, name := range allGCNames { gc := createGC(name) diff --git a/internal/framework/status/updater_retry_test.go b/internal/framework/status/updater_retry_test.go index 80466e6590..7768d78ad5 100644 --- a/internal/framework/status/updater_retry_test.go +++ b/internal/framework/status/updater_retry_test.go @@ -5,12 +5,12 @@ import ( "errors" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginx/nginx-gateway-fabric/internal/framework/controller/controllerfakes" @@ -86,7 +86,7 @@ func TestNewRetryUpdateFunc(t *testing.T) { fakeStatusUpdater, types.NamespacedName{}, &v1.GatewayClass{}, - zap.New(), + logr.Discard(), func(client.Object) bool { return test.statusSetterReturns }, ) diff --git a/internal/framework/status/updater_test.go b/internal/framework/status/updater_test.go index e053517da7..b72faf4b3d 100644 --- a/internal/framework/status/updater_test.go +++ b/internal/framework/status/updater_test.go @@ -3,6 +3,7 @@ package status import ( "context" + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -10,7 +11,6 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" "github.com/nginx/nginx-gateway-fabric/internal/framework/helpers" @@ -116,7 +116,7 @@ var _ = Describe("Updater", func() { ) BeforeAll(func() { - updater = NewUpdater(k8sClient, zap.New()) + updater = NewUpdater(k8sClient, logr.Discard()) for _, name := range gcNames { gc := createGC(name) diff --git a/internal/mode/provisioner/handler_test.go b/internal/mode/provisioner/handler_test.go index ee24ada683..97c870179e 100644 --- a/internal/mode/provisioner/handler_test.go +++ b/internal/mode/provisioner/handler_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/apps/v1" apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -12,7 +13,6 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/log/zap" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" . "github.com/onsi/gomega" @@ -60,7 +60,7 @@ var _ = Describe("handler", func() { return fakeTime } - statusUpdater = status.NewUpdater(k8sclient, zap.New()) + statusUpdater = status.NewUpdater(k8sclient, logr.Discard()) // Add GatewayClass CRD to the cluster crd = &metav1.PartialObjectMetadata{ @@ -114,7 +114,7 @@ var _ = Describe("handler", func() { Resource: crd, }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) // Ensure GatewayClass is accepted @@ -152,7 +152,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) depNsName := types.NamespacedName{ Namespace: "nginx-gateway", @@ -187,7 +187,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) updatedGC := &gatewayv1.GatewayClass{} @@ -249,7 +249,7 @@ var _ = Describe("handler", func() { } handle := func() { - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) } Expect(handle).Should(Panic()) @@ -310,7 +310,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) deps := &v1.DeploymentList{} err := k8sclient.List(context.Background(), deps) @@ -330,7 +330,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) deps := &v1.DeploymentList{} @@ -359,7 +359,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) deps := &v1.DeploymentList{} err := k8sclient.List(context.Background(), deps) @@ -392,7 +392,7 @@ var _ = Describe("handler", func() { }, } - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) unknownGC := &gatewayv1.GatewayClass{} err = k8sclient.Get(context.Background(), client.ObjectKeyFromObject(newGC), unknownGC) @@ -456,7 +456,7 @@ var _ = Describe("handler", func() { batch := []interface{}{e} handle := func() { - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) } Expect(handle).Should(Panic()) @@ -524,7 +524,7 @@ var _ = Describe("handler", func() { } handle := func() { - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) } Expect(handle).Should(Panic()) @@ -545,7 +545,7 @@ var _ = Describe("handler", func() { } handle := func() { - handler.HandleEventBatch(context.Background(), zap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) } Expect(handle).Should(Panic()) diff --git a/internal/mode/static/config_updater_test.go b/internal/mode/static/config_updater_test.go index 7b5f77029b..440f7dde22 100644 --- a/internal/mode/static/config_updater_test.go +++ b/internal/mode/static/config_updater_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "sigs.k8s.io/controller-runtime/pkg/log/zap" ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1" "github.com/nginx/nginx-gateway-fabric/internal/framework/helpers" @@ -33,7 +33,7 @@ func TestUpdateControlPlane(t *testing.T) { }, } - logger := zap.New() + logger := logr.Discard() nsname := types.NamespacedName{Namespace: "test", Name: "test"} tests := []struct { diff --git a/internal/mode/static/handler_test.go b/internal/mode/static/handler_test.go index d210509989..5774487650 100644 --- a/internal/mode/static/handler_test.go +++ b/internal/mode/static/handler_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" + "github.com/go-logr/logr" ngxclient "github.com/nginxinc/nginx-plus-go-client/client" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -15,7 +16,6 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1" @@ -154,7 +154,7 @@ var _ = Describe("eventHandler", func() { e := &events.UpsertEvent{Resource: &gatewayv1.HTTPRoute{}} batch := []interface{}{e} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 1) @@ -170,7 +170,7 @@ var _ = Describe("eventHandler", func() { } batch := []interface{}{e} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 1) @@ -189,12 +189,12 @@ var _ = Describe("eventHandler", func() { } batch := []interface{}{upsertEvent, deleteEvent} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) checkUpsertEventExpectations(upsertEvent) checkDeleteEventExpectations(deleteEvent) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 2) Expect(helpers.Diff(handler.GetLatestConfiguration(), &dcfg)).To(BeEmpty()) @@ -239,7 +239,7 @@ var _ = Describe("eventHandler", func() { expectedReqsCount = 2 } - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(fakeStatusUpdater.UpdateGroupCallCount()).To(Equal(2)) @@ -275,7 +275,7 @@ var _ = Describe("eventHandler", func() { It("handles a valid config", func() { batch := []interface{}{&events.UpsertEvent{Resource: cfg(ngfAPI.ControllerLogLevelError)}} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) @@ -290,7 +290,7 @@ var _ = Describe("eventHandler", func() { It("handles an invalid config", func() { batch := []interface{}{&events.UpsertEvent{Resource: cfg(ngfAPI.ControllerLogLevel("invalid"))}} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) @@ -318,7 +318,7 @@ var _ = Describe("eventHandler", func() { }, }, } - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) @@ -351,7 +351,7 @@ var _ = Describe("eventHandler", func() { }} batch := []interface{}{e} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(fakeStatusUpdater.UpdateGroupCallCount()).To(BeZero()) @@ -359,7 +359,7 @@ var _ = Describe("eventHandler", func() { batch = []interface{}{de} Expect(fakeK8sClient.Delete(context.Background(), createService(notNginxGatewayServiceName))).To(Succeed()) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) @@ -375,7 +375,7 @@ var _ = Describe("eventHandler", func() { }} batch := []interface{}{e} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) Expect(fakeStatusUpdater.UpdateGroupCallCount()).To(Equal(1)) @@ -395,7 +395,7 @@ var _ = Describe("eventHandler", func() { batch := []interface{}{e} Expect(fakeK8sClient.Delete(context.Background(), createService(nginxGatewayServiceName))).To(Succeed()) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) Expect(fakeStatusUpdater.UpdateGroupCallCount()).To(Equal(1)) @@ -439,7 +439,7 @@ var _ = Describe("eventHandler", func() { It("should call the NGINX Plus API", func() { handler.cfg.plus = true - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 1) dcfg.NginxPlus = dataplane.NginxPlus{AllowedAddresses: []string{"127.0.0.1"}} @@ -453,7 +453,7 @@ var _ = Describe("eventHandler", func() { When("not running NGINX Plus", func() { It("should not call the NGINX Plus API", func() { - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 1) Expect(helpers.Diff(handler.GetLatestConfiguration(), &dcfg)).To(BeEmpty()) @@ -543,7 +543,7 @@ var _ = Describe("eventHandler", func() { fakeProcessor.ProcessReturns(state.ClusterStateChange, &graph.Graph{}) Expect(handler.cfg.nginxConfiguredOnStartChecker.readyCheck(nil)).ToNot(Succeed()) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 1) Expect(helpers.Diff(handler.GetLatestConfiguration(), &dcfg)).To(BeEmpty()) @@ -559,7 +559,7 @@ var _ = Describe("eventHandler", func() { readyChannel := handler.cfg.nginxConfiguredOnStartChecker.getReadyCh() Expect(handler.cfg.nginxConfiguredOnStartChecker.readyCheck(nil)).ToNot(Succeed()) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.GetLatestConfiguration()).To(BeNil()) @@ -576,14 +576,14 @@ var _ = Describe("eventHandler", func() { fakeProcessor.ProcessReturns(state.ClusterStateChange, &graph.Graph{}) fakeNginxRuntimeMgr.ReloadReturns(errors.New("reload error")) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.cfg.nginxConfiguredOnStartChecker.readyCheck(nil)).ToNot(Succeed()) // now send an update with no changes; should still return an error fakeProcessor.ProcessReturns(state.NoChange, &graph.Graph{}) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) Expect(handler.cfg.nginxConfiguredOnStartChecker.readyCheck(nil)).ToNot(Succeed()) @@ -591,7 +591,7 @@ var _ = Describe("eventHandler", func() { fakeProcessor.ProcessReturns(state.ClusterStateChange, &graph.Graph{}) fakeNginxRuntimeMgr.ReloadReturns(nil) - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) dcfg := dataplane.GetDefaultConfiguration(&graph.Graph{}, 2) Expect(helpers.Diff(handler.GetLatestConfiguration(), &dcfg)).To(BeEmpty()) @@ -606,7 +606,7 @@ var _ = Describe("eventHandler", func() { handle := func() { batch := []interface{}{e} - handler.HandleEventBatch(context.Background(), ctlrZap.New(), batch) + handler.HandleEventBatch(context.Background(), logr.Discard(), batch) } Expect(handle).Should(Panic()) diff --git a/internal/mode/static/nginx/config/generator_test.go b/internal/mode/static/nginx/config/generator_test.go index a33a2b3a81..79bb35a90f 100644 --- a/internal/mode/static/nginx/config/generator_test.go +++ b/internal/mode/static/nginx/config/generator_test.go @@ -5,9 +5,9 @@ import ( "sort" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" - ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/framework/helpers" ngfConfig "github.com/nginx/nginx-gateway-fabric/internal/mode/static/config" @@ -140,7 +140,7 @@ func TestGenerate(t *testing.T) { generator := config.NewGeneratorImpl( plus, &ngfConfig.UsageReportConfig{Endpoint: "test-endpoint"}, - ctlrZap.New(), + logr.Discard(), ) files := generator.Generate(conf) diff --git a/internal/mode/static/nginx/file/manager_test.go b/internal/mode/static/nginx/file/manager_test.go index 1f0d5fa8a3..114b81c3dc 100644 --- a/internal/mode/static/nginx/file/manager_test.go +++ b/internal/mode/static/nginx/file/manager_test.go @@ -5,9 +5,9 @@ import ( "os" "path/filepath" + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/file" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/file/filefakes" @@ -60,7 +60,7 @@ var _ = Describe("EventHandler", func() { } BeforeAll(func() { - mgr = file.NewManagerImpl(zap.New(), file.NewStdLibOSFileManager()) + mgr = file.NewManagerImpl(logr.Discard(), file.NewStdLibOSFileManager()) tmpDir = GinkgoT().TempDir() regular1 = file.File{ @@ -119,7 +119,7 @@ var _ = Describe("EventHandler", func() { When("file does not exist", func() { It("should not error", func() { fakeOSMgr := &filefakes.FakeOSFileManager{} - mgr := file.NewManagerImpl(zap.New(), fakeOSMgr) + mgr := file.NewManagerImpl(logr.Discard(), fakeOSMgr) files := []file.File{ { @@ -138,7 +138,7 @@ var _ = Describe("EventHandler", func() { When("file type is not supported", func() { It("should panic", func() { - mgr := file.NewManagerImpl(zap.New(), nil) + mgr := file.NewManagerImpl(logr.Discard(), nil) files := []file.File{ { @@ -175,7 +175,7 @@ var _ = Describe("EventHandler", func() { DescribeTable( "should return error on file IO error", func(fakeOSMgr *filefakes.FakeOSFileManager) { - mgr := file.NewManagerImpl(zap.New(), fakeOSMgr) + mgr := file.NewManagerImpl(logr.Discard(), fakeOSMgr) // special case for Remove // to kick off removing, we need to successfully write files beforehand diff --git a/internal/mode/static/nginx/runtime/manager_test.go b/internal/mode/static/nginx/runtime/manager_test.go index e029a255ce..1c40c03513 100644 --- a/internal/mode/static/nginx/runtime/manager_test.go +++ b/internal/mode/static/nginx/runtime/manager_test.go @@ -8,10 +8,10 @@ import ( "testing" "time" + "github.com/go-logr/logr" ngxclient "github.com/nginxinc/nginx-plus-go-client/client" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/runtime" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/runtime/runtimefakes" @@ -19,10 +19,10 @@ import ( var _ = Describe("NGINX Runtime Manager", func() { It("returns whether or not we're using NGINX Plus", func() { - mgr := runtime.NewManagerImpl(nil, nil, zap.New(), nil, nil) + mgr := runtime.NewManagerImpl(nil, nil, logr.Discard(), nil, nil) Expect(mgr.IsPlus()).To(BeFalse()) - mgr = runtime.NewManagerImpl(&ngxclient.NginxClient{}, nil, zap.New(), nil, nil) + mgr = runtime.NewManagerImpl(&ngxclient.NginxClient{}, nil, logr.Discard(), nil, nil) Expect(mgr.IsPlus()).To(BeTrue()) }) @@ -53,7 +53,7 @@ var _ = Describe("NGINX Runtime Manager", func() { process = &runtimefakes.FakeProcessHandler{} metrics = &runtimefakes.FakeMetricsCollector{} verifyClient = &runtimefakes.FakeVerifyClient{} - manager = runtime.NewManagerImpl(ngxPlusClient, metrics, zap.New(), process, verifyClient) + manager = runtime.NewManagerImpl(ngxPlusClient, metrics, logr.Discard(), process, verifyClient) }) It("Is successful", func() { @@ -117,7 +117,7 @@ var _ = Describe("NGINX Runtime Manager", func() { When("MetricsCollector is nil", func() { It("panics", func() { metrics = nil - manager = runtime.NewManagerImpl(ngxPlusClient, metrics, zap.New(), process, verifyClient) + manager = runtime.NewManagerImpl(ngxPlusClient, metrics, logr.Discard(), process, verifyClient) reload := func() { err = manager.Reload(context.Background(), 0) @@ -132,7 +132,7 @@ var _ = Describe("NGINX Runtime Manager", func() { It("panics", func() { metrics = &runtimefakes.FakeMetricsCollector{} verifyClient = nil - manager = runtime.NewManagerImpl(ngxPlusClient, metrics, zap.New(), process, verifyClient) + manager = runtime.NewManagerImpl(ngxPlusClient, metrics, logr.Discard(), process, verifyClient) reload := func() { err = manager.Reload(context.Background(), 0) @@ -147,7 +147,7 @@ var _ = Describe("NGINX Runtime Manager", func() { When("running NGINX plus", func() { BeforeEach(func() { ngxPlusClient = &runtimefakes.FakeNginxPlusClient{} - manager = runtime.NewManagerImpl(ngxPlusClient, nil, zap.New(), nil, nil) + manager = runtime.NewManagerImpl(ngxPlusClient, nil, logr.Discard(), nil, nil) }) It("successfully updates HTTP server upstream", func() { @@ -263,7 +263,7 @@ var _ = Describe("NGINX Runtime Manager", func() { When("not running NGINX plus", func() { BeforeEach(func() { ngxPlusClient = nil - manager = runtime.NewManagerImpl(ngxPlusClient, nil, zap.New(), nil, nil) + manager = runtime.NewManagerImpl(ngxPlusClient, nil, logr.Discard(), nil, nil) }) It("should panic when fetching upstream servers", func() { diff --git a/internal/mode/static/state/change_processor_test.go b/internal/mode/static/state/change_processor_test.go index 7211a5f045..e899bdaa40 100644 --- a/internal/mode/static/state/change_processor_test.go +++ b/internal/mode/static/state/change_processor_test.go @@ -1,6 +1,7 @@ package state_test import ( + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/format" @@ -13,7 +14,6 @@ import ( "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/apis/v1alpha3" @@ -414,7 +414,7 @@ var _ = Describe("ChangeProcessor", func() { processor = state.NewChangeProcessorImpl(state.ChangeProcessorConfig{ GatewayCtlrName: controllerName, GatewayClassName: gcName, - Logger: zap.New(), + Logger: logr.Discard(), Validators: createAlwaysValidValidators(), MustExtractGVK: kinds.NewMustExtractGKV(createScheme()), }) @@ -2181,7 +2181,7 @@ var _ = Describe("ChangeProcessor", func() { processor = state.NewChangeProcessorImpl(state.ChangeProcessorConfig{ GatewayCtlrName: controllerName, GatewayClassName: gcName, - Logger: zap.New(), + Logger: logr.Discard(), Validators: createAlwaysValidValidators(), MustExtractGVK: kinds.NewMustExtractGKV(createScheme()), }) diff --git a/internal/mode/static/status/prepare_requests_test.go b/internal/mode/static/status/prepare_requests_test.go index 702cbe9827..5d7eb9f2ea 100644 --- a/internal/mode/static/status/prepare_requests_test.go +++ b/internal/mode/static/status/prepare_requests_test.go @@ -5,6 +5,7 @@ import ( "errors" "testing" + "github.com/go-logr/logr" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -13,7 +14,6 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/log/zap" v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/apis/v1alpha3" @@ -268,7 +268,7 @@ func TestBuildHTTPRouteStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareRouteRequests( map[graph.L4RouteKey]*graph.L4Route{}, @@ -347,7 +347,7 @@ func TestBuildGRPCRouteStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareRouteRequests( map[graph.L4RouteKey]*graph.L4Route{}, @@ -424,7 +424,7 @@ func TestBuildTLSRouteStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareRouteRequests( routes, @@ -528,7 +528,7 @@ func TestBuildRouteStatusesNginxErr(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareRouteRequests( map[graph.L4RouteKey]*graph.L4Route{}, @@ -662,7 +662,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) { expectedTotalReqs++ } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareGatewayClassRequests(test.gc, test.ignoredClasses, transitionTime) @@ -1158,7 +1158,7 @@ func TestBuildGatewayStatuses(t *testing.T) { expectedTotalReqs++ } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareGatewayRequests( test.gateway, @@ -1376,7 +1376,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareBackendTLSPolicyRequests(test.backendTLSPolicies, transitionTime, gatewayCtlrName) @@ -1470,7 +1470,7 @@ func TestBuildNginxGatewayStatus(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) req := PrepareNginxGatewayStatus(test.nginxGateway, transitionTime, test.cpUpdateResult) @@ -1764,7 +1764,7 @@ func TestBuildNGFPolicyStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareNGFPolicyRequests(test.policies, transitionTime, gatewayCtlrName) @@ -1894,7 +1894,7 @@ func TestBuildSnippetsFilterStatuses(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) } - updater := statusFramework.NewUpdater(k8sClient, zap.New()) + updater := statusFramework.NewUpdater(k8sClient, logr.Discard()) reqs := PrepareSnippetsFilterRequests(test.snippetsFilters, transitionTime, gatewayCtlrName) diff --git a/internal/mode/static/telemetry/job_worker_test.go b/internal/mode/static/telemetry/job_worker_test.go index 770af9892c..8855fd5d8b 100644 --- a/internal/mode/static/telemetry/job_worker_test.go +++ b/internal/mode/static/telemetry/job_worker_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" + "github.com/go-logr/logr" tel "github.com/nginx/telemetry-exporter/pkg/telemetry" . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/telemetry" "github.com/nginx/nginx-gateway-fabric/internal/mode/static/telemetry/telemetryfakes" @@ -21,7 +21,7 @@ func TestCreateTelemetryJobWorker_Succeeds(t *testing.T) { exporter := &telemetryfakes.FakeExporter{} dataCollector := &telemetryfakes.FakeDataCollector{} - worker := telemetry.CreateTelemetryJobWorker(zap.New(), exporter, dataCollector) + worker := telemetry.CreateTelemetryJobWorker(logr.Discard(), exporter, dataCollector) expData := telemetry.Data{ Data: tel.Data{ @@ -46,7 +46,7 @@ func TestCreateTelemetryJobWorker_CollectFails(t *testing.T) { exporter := &telemetryfakes.FakeExporter{} dataCollector := &telemetryfakes.FakeDataCollector{} - worker := telemetry.CreateTelemetryJobWorker(zap.New(), exporter, dataCollector) + worker := telemetry.CreateTelemetryJobWorker(logr.Discard(), exporter, dataCollector) expData := telemetry.Data{} dataCollector.CollectReturns(expData, errors.New("failed to collect cluster information"))