diff --git a/go.mod b/go.mod index 7d9e513b942..0f57c658c25 100644 --- a/go.mod +++ b/go.mod @@ -71,6 +71,7 @@ require ( github.com/krishicks/yaml-patch v0.0.10 github.com/markbates/inflect v1.0.4 // indirect github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect + github.com/mattn/go-colorable v0.1.4 github.com/mitchellh/go-homedir v1.1.0 github.com/moby/buildkit v0.6.3 github.com/onsi/ginkgo v1.10.3 // indirect diff --git a/pkg/skaffold/build/buildpacks/lifecycle.go b/pkg/skaffold/build/buildpacks/lifecycle.go index 1f17f252526..4dc152f3cd5 100644 --- a/pkg/skaffold/build/buildpacks/lifecycle.go +++ b/pkg/skaffold/build/buildpacks/lifecycle.go @@ -22,14 +22,12 @@ import ( "strings" "github.com/buildpacks/pack" - "github.com/heroku/color" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/misc" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" - "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" ) // For testing @@ -85,12 +83,6 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact, } func runPackBuild(ctx context.Context, out io.Writer, localDocker docker.LocalDaemon, opts pack.BuildOptions) error { - // If out is not a terminal, let's make sure pack doesn't output with colors. - if _, isTerm := util.IsTerminal(out); !isTerm { - // pack uses heroku/color under the hood. - color.Disable(true) - } - packClient, err := pack.NewClient( pack.WithDockerClient(localDocker.RawClient()), pack.WithLogger(NewLogger(out)), diff --git a/pkg/skaffold/build/buildpacks/logger.go b/pkg/skaffold/build/buildpacks/logger.go index 576ebea3188..394bcd83088 100644 --- a/pkg/skaffold/build/buildpacks/logger.go +++ b/pkg/skaffold/build/buildpacks/logger.go @@ -20,7 +20,10 @@ import ( "io" "github.com/buildpacks/pack/logging" + "github.com/mattn/go-colorable" "github.com/sirupsen/logrus" + + "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" ) // logger exists to meet the requirements of the pack logger. @@ -30,12 +33,27 @@ type logger struct { } func NewLogger(out io.Writer) logging.Logger { + // If out is not a terminal, let's make sure no colors are printed. + if _, isTerm := util.IsTerminal(out); !isTerm { + out = colorable.NewNonColorable(out) + } + + l := logrus.New() + l.SetOutput(out) + l.SetFormatter(new(plainFormatter)) + return &logger{ - Logger: logrus.StandardLogger(), + Logger: l, out: out, } } +type plainFormatter struct{} + +func (f *plainFormatter) Format(entry *logrus.Entry) ([]byte, error) { + return []byte(entry.Message + "\n"), nil +} + func (l *logger) Debug(msg string) { l.Logger.Debug(msg) }