From d7820215df7132b168c84a3b03a586f079eb098e Mon Sep 17 00:00:00 2001 From: Tom George Date: Sun, 19 Jan 2020 23:29:49 -0500 Subject: [PATCH] Change the loggers in entrypoint, creds-init, and pullrequest-init to use the default Zap sugared logger. Previously, these loggers cluttered Task output with messages about being unable to fetch ko information. This addresses #1145 --- cmd/creds-init/main.go | 6 ++++-- cmd/git-init/main.go | 6 +++--- cmd/pullrequest-init/main.go | 4 ++-- go.mod | 2 ++ pkg/entrypoint/entrypointer.go | 5 +++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/creds-init/main.go b/cmd/creds-init/main.go index 72b6f891a53..09eb69906ac 100644 --- a/cmd/creds-init/main.go +++ b/cmd/creds-init/main.go @@ -17,18 +17,20 @@ package main import ( "flag" + "go.uber.org/zap" "github.com/tektoncd/pipeline/pkg/credentials" "github.com/tektoncd/pipeline/pkg/credentials/dockercreds" "github.com/tektoncd/pipeline/pkg/credentials/gitcreds" - "knative.dev/pkg/logging" ) func main() { flag.Parse() + prod, _ := zap.NewProduction() + logger := prod.Sugar() + // ignore atomic level because we are not watching this config for any updates - logger, _ := logging.NewLogger("", "creds-init") defer func() { _ = logger.Sync() }() diff --git a/cmd/git-init/main.go b/cmd/git-init/main.go index c2fb5d8b447..93ab3119280 100644 --- a/cmd/git-init/main.go +++ b/cmd/git-init/main.go @@ -17,11 +17,11 @@ package main import ( "flag" + "go.uber.org/zap" v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/git" "github.com/tektoncd/pipeline/pkg/termination" - "knative.dev/pkg/logging" ) var ( @@ -42,8 +42,8 @@ func init() { func main() { flag.Parse() - - logger, _ := logging.NewLogger("", "git-init") + prod, _ := zap.NewProduction() + logger := prod.Sugar() defer func() { _ = logger.Sync() }() diff --git a/cmd/pullrequest-init/main.go b/cmd/pullrequest-init/main.go index 80414bfc9ee..20e4f17e7c4 100644 --- a/cmd/pullrequest-init/main.go +++ b/cmd/pullrequest-init/main.go @@ -23,7 +23,6 @@ import ( "github.com/tektoncd/pipeline/pkg/pullrequest" "go.uber.org/zap" - "knative.dev/pkg/logging" ) var ( @@ -36,7 +35,8 @@ var ( func main() { flag.Parse() - logger, _ := logging.NewLogger("", "pullrequest-init") + prod, _ := zap.NewProduction() + logger := prod.Sugar() logger = logger.With( zap.String("resource_type", "pullrequest"), zap.String("mode", *mode)) diff --git a/go.mod b/go.mod index d67316e45af..ea87d88898a 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( cloud.google.com/go v0.47.0 // indirect + cloud.google.com/go/storage v1.0.0 contrib.go.opencensus.io/exporter/prometheus v0.1.0 // indirect contrib.go.opencensus.io/exporter/stackdriver v0.12.8 // indirect github.com/GoogleCloudPlatform/cloud-builders/gcs-fetcher v0.0.0-20191203181535-308b93ad1f39 @@ -40,6 +41,7 @@ require ( golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + google.golang.org/api v0.10.0 google.golang.org/appengine v1.6.5 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.2.5 // indirect diff --git a/pkg/entrypoint/entrypointer.go b/pkg/entrypoint/entrypointer.go index fa7c4a52cae..cf218d6dc1a 100644 --- a/pkg/entrypoint/entrypointer.go +++ b/pkg/entrypoint/entrypointer.go @@ -18,6 +18,7 @@ package entrypoint import ( "fmt" + "go.uber.org/zap" "io/ioutil" "os" "path/filepath" @@ -25,7 +26,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/logging" "github.com/tektoncd/pipeline/pkg/termination" ) @@ -80,7 +80,8 @@ type PostWriter interface { // Go optionally waits for a file, runs the command, and writes a // post file. func (e Entrypointer) Go() error { - logger, _ := logging.NewLogger("", "entrypoint") + prod, _ := zap.NewProduction() + logger := prod.Sugar() defer func() { _ = logger.Sync() }()