Skip to content

Commit

Permalink
Switch other uses
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek committed Aug 28, 2024
1 parent 875159d commit 708be68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion v2/internal/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ func setup() error {

// If you need to debug envtest setup/teardown,
// set a global logger for controller-runtime:
//
// import (ctrl "sigs.k8s.io/controller-runtime")
// ctrl.SetLogger(klogr.New())
// cfg := textlogger.NewConfig(textlogger.Verbosity(3)) // Use verbose logging in tests
// log := textlogger.NewLogger(cfg)
// ctrl.SetLogger(log)

nameConfig := testcommon.NewResourceNameConfig(
testcommon.ResourcePrefix,
Expand Down
18 changes: 12 additions & 6 deletions v2/internal/testcommon/kube_test_context_envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/envtest"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -88,10 +87,13 @@ func createSharedEnvTest(cfg testConfig, namespaceResources *namespaceResources)
Scheme: scheme,
}

// TODO: Switch to klogr.New() below the below if we want controller-runtime logs in the tests.
// Switch logger below if we want controller-runtime logs in the tests.
// By default we've disabled controller runtime logs because they're very verbose and usually not useful.
// ctrl.SetLogger(klogr.New())
ctrl.SetLogger(logr.New(ctrllog.NullLogSink{}))
// import (ctrl "sigs.k8s.io/controller-runtime")
// cfg := textlogger.NewConfig(textlogger.Verbosity(3)) // Use verbose logging in tests
// log := textlogger.NewLogger(cfg)
// ctrl.SetLogger(log)
ctrl.SetLogger(logr.Discard())

log.Println("Starting envtest")
kubeConfig, err := environment.Start()
Expand Down Expand Up @@ -159,8 +161,12 @@ func createSharedEnvTest(cfg testConfig, namespaceResources *namespaceResources)

// TODO: Uncomment the below if we want controller-runtime logs in the tests.
// By default we've disabled controller runtime logs because they're very verbose and usually not useful.
// ctrl.SetLogger(klogr.New())
ctrl.SetLogger(logr.New(ctrllog.NullLogSink{}))
//
// import (ctrl "sigs.k8s.io/controller-runtime")
// cfg := textlogger.NewConfig(textlogger.Verbosity(3)) // Use verbose logging in tests
// log := textlogger.NewLogger(cfg)
// ctrl.SetLogger(log)
ctrl.SetLogger(logr.Discard())

loggerFactory := func(obj metav1.Object) logr.Logger {
result := namespaceResources.Lookup(obj.GetNamespace())
Expand Down
5 changes: 4 additions & 1 deletion v2/pkg/genruntime/test/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ func setup() error {

// If you need to debug envtest setup/teardown,
// set a global logger for controller-runtime:
//
// import (ctrl "sigs.k8s.io/controller-runtime")
// ctrl.SetLogger(klogr.New())
// cfg := textlogger.NewConfig(textlogger.Verbosity(3)) // Use verbose logging in tests
// log := textlogger.NewLogger(cfg)
// ctrl.SetLogger(log)

nameConfig := testcommon.NewResourceNameConfig(
testcommon.ResourcePrefix,
Expand Down

0 comments on commit 708be68

Please sign in to comment.