Skip to content

Commit

Permalink
Change the loggers in entrypoint, creds-init, and pullrequest-init to…
Browse files Browse the repository at this point in the history
… use the default Zap sugared logger.

Previously, these loggers cluttered Task output with messages about being unable to fetch ko information.

This addresses #1145
  • Loading branch information
tomgeorge authored and tekton-robot committed Feb 5, 2020
1 parent f4e2e44 commit d782021
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions cmd/creds-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}()
Expand Down
6 changes: 3 additions & 3 deletions cmd/git-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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()
}()
Expand Down
4 changes: 2 additions & 2 deletions cmd/pullrequest-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/tektoncd/pipeline/pkg/pullrequest"
"go.uber.org/zap"
"knative.dev/pkg/logging"
)

var (
Expand All @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/entrypoint/entrypointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package entrypoint

import (
"fmt"
"go.uber.org/zap"
"io/ioutil"
"os"
"path/filepath"
"time"

"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"
)

Expand Down Expand Up @@ -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()
}()
Expand Down

0 comments on commit d782021

Please sign in to comment.