set controller-runtime logger to a null logger
This is required because controller-runtime expects its consumers to set a logger through log.SetLogger within 30 seconds of the program's initalization. If not set, the entire debug stack is printed as an error. Ref: https://github.com/kubernetes-sigs/controller-runtime/blob/ed8be90/pkg/log/log.go#L59 Since we have our own logging and don't care about controller-runtime's logger, we configure it's logger to do nothing. Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
@@ -24,12 +24,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/term"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
|
||||
|
||||
runclient "github.com/fluxcd/pkg/runtime/client"
|
||||
|
||||
@@ -170,6 +172,15 @@ func NewRootFlags() rootFlags {
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
|
||||
// This is required because controller-runtime expects its consumers to
|
||||
// set a logger through log.SetLogger within 30 seconds of the program's
|
||||
// initalization. If not set, the entire debug stack is printed as an
|
||||
// error, see: https://github.com/kubernetes-sigs/controller-runtime/blob/ed8be90/pkg/log/log.go#L59
|
||||
// Since we have our own logging and don't care about controller-runtime's
|
||||
// logger, we configure it's logger to do nothing.
|
||||
ctrllog.SetLogger(logr.New(ctrllog.NullLogSink{}))
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
|
||||
if err, ok := err.(*RequestError); ok {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -27,6 +27,7 @@ require (
|
||||
github.com/fluxcd/pkg/version v0.2.2
|
||||
github.com/fluxcd/source-controller/api v1.0.0-rc.4
|
||||
github.com/go-git/go-git/v5 v5.7.0
|
||||
github.com/go-logr/logr v1.2.4
|
||||
github.com/gonvenience/bunt v1.3.5
|
||||
github.com/gonvenience/ytbx v1.4.4
|
||||
github.com/google/go-cmp v0.5.9
|
||||
@@ -117,7 +118,6 @@ require (
|
||||
github.com/go-errors/errors v1.4.2 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.4.1 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
|
||||
Reference in New Issue
Block a user