From 8ca83f8ce181f6319b0502610b2ef2fac7f86f2d Mon Sep 17 00:00:00 2001 From: Corey Daley Date: Thu, 1 Oct 2020 20:59:50 -0400 Subject: [PATCH] code changes for k8s.io/klog/v2 --- cmd/s2i/s2i.go | 2 +- pkg/cmd/cli/util/util.go | 2 +- pkg/scm/downloaders/git/clone.go | 2 +- pkg/util/log/log.go | 6 +++--- test/integration/docker/integration_test.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/s2i/s2i.go b/cmd/s2i/s2i.go index 913fbbf5b..0c198f1cf 100644 --- a/cmd/s2i/s2i.go +++ b/cmd/s2i/s2i.go @@ -8,7 +8,7 @@ import ( "runtime" "time" - "k8s.io/klog" + "k8s.io/klog/v2" "github.com/openshift/source-to-image/pkg/cmd/cli" ) diff --git a/pkg/cmd/cli/util/util.go b/pkg/cmd/cli/util/util.go index f5f33ee28..80b010b83 100644 --- a/pkg/cmd/cli/util/util.go +++ b/pkg/cmd/cli/util/util.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - log "k8s.io/klog" + log "k8s.io/klog/v2" "github.com/openshift/source-to-image/pkg/api" ) diff --git a/pkg/scm/downloaders/git/clone.go b/pkg/scm/downloaders/git/clone.go index c5fced622..ff944368e 100644 --- a/pkg/scm/downloaders/git/clone.go +++ b/pkg/scm/downloaders/git/clone.go @@ -5,7 +5,7 @@ import ( "path/filepath" "runtime" - "k8s.io/klog" + "k8s.io/klog/v2" "github.com/openshift/source-to-image/pkg/api" "github.com/openshift/source-to-image/pkg/api/constants" diff --git a/pkg/util/log/log.go b/pkg/util/log/log.go index b2906a0f6..15b458a01 100644 --- a/pkg/util/log/log.go +++ b/pkg/util/log/log.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - "k8s.io/klog" + "k8s.io/klog/v2" ) // Logger is a simple interface that is roughly equivalent to klog. @@ -109,7 +109,7 @@ func (f *FileLogger) Is(level int32) bool { // V will returns a logger which will discard output if the specified level is greater than the current logging level. func (f *FileLogger) V(level int32) VerboseLogger { // Is the loglevel set verbose enough to accept the forthcoming log statement - if klog.V(klog.Level(level)) { + if klog.V(klog.Level(level)).Enabled() { return f } // Otherwise discard @@ -147,7 +147,7 @@ func (f *FileLogger) writeln(sev severity, line string) { // If the loglevel has been elevated above this file logger's verbosity (generally set to 2) // then delegate ALL messages to elevated logger in order to leverage its file/line/timestamp // prefix information. - if klog.V(klog.Level(f.level + 1)) { + if klog.V(klog.Level(f.level + 1)).Enabled() { severity.delegateFn(3, line) } else { // buf.io is not threadsafe, so serialize access to the stream diff --git a/test/integration/docker/integration_test.go b/test/integration/docker/integration_test.go index 153df7d1e..b5197ebc2 100644 --- a/test/integration/docker/integration_test.go +++ b/test/integration/docker/integration_test.go @@ -21,7 +21,7 @@ import ( dockerapi "github.com/docker/docker/client" "golang.org/x/net/context" - "k8s.io/klog" + "k8s.io/klog/v2" "github.com/openshift/source-to-image/pkg/api" "github.com/openshift/source-to-image/pkg/build" @@ -195,7 +195,7 @@ func (i *integrationTest) setup() { from := flag.CommandLine if vflag := from.Lookup("v"); vflag != nil { // the thing here is that we are looking for the bash -v passed into test-integration.sh (with no value), - // but for klog (https://k8s.io/klog/blob/master/klog.go), one specifies + // but for klog (https://k8s.io/klog/v2/blob/master/klog.go), one specifies // the logging level with -v=# (i.e. -v=0 or -v=3 or -v=5). // so, for the changes stemming from issue 133, we 'reuse' the bash -v, and set the highest klog level. // (if you look at STI's main.go, and setupGlog, it essentially maps klog's -v to --loglevel for use by the sti command)