From 2d7540fb0ae80e7059117f75c1aa5850d45b3302 Mon Sep 17 00:00:00 2001 From: Edgar Lee Date: Sat, 5 Feb 2022 13:57:33 -0800 Subject: [PATCH] Separate io.Writer from console.File for NewPrinter Signed-off-by: Edgar Lee --- commands/bake.go | 2 +- commands/build.go | 2 +- commands/util.go | 2 +- util/progress/printer.go | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/commands/bake.go b/commands/bake.go index c6bc9ba8..db7b9498 100644 --- a/commands/bake.go +++ b/commands/bake.go @@ -76,7 +76,7 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions) (err error ctx2, cancel := context.WithCancel(context.TODO()) defer cancel() - printer := progress.NewPrinter(ctx2, os.Stderr, in.progress) + printer := progress.NewPrinter(ctx2, os.Stderr, os.Stderr, in.progress) defer func() { if printer != nil { diff --git a/commands/build.go b/commands/build.go index 2861820c..404f9564 100644 --- a/commands/build.go +++ b/commands/build.go @@ -239,7 +239,7 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, opts map[string]bu ctx2, cancel := context.WithCancel(context.TODO()) defer cancel() - printer := progress.NewPrinter(ctx2, os.Stderr, progressMode) + printer := progress.NewPrinter(ctx2, os.Stderr, os.Stderr, progressMode) resp, err := build.Build(ctx, dis, opts, dockerAPI(dockerCli), confutil.ConfigDir(dockerCli), printer) err1 := printer.Wait() diff --git a/commands/util.go b/commands/util.go index 03c28684..03a6e416 100644 --- a/commands/util.go +++ b/commands/util.go @@ -414,7 +414,7 @@ func boot(ctx context.Context, ngi *nginfo) (bool, error) { return false, nil } - printer := progress.NewPrinter(context.TODO(), os.Stderr, "auto") + printer := progress.NewPrinter(context.TODO(), os.Stderr, os.Stderr, "auto") baseCtx := ctx eg, _ := errgroup.WithContext(ctx) diff --git a/util/progress/printer.go b/util/progress/printer.go index ba346b5b..86be5fb6 100644 --- a/util/progress/printer.go +++ b/util/progress/printer.go @@ -41,7 +41,7 @@ func (p *Printer) Warnings() []client.VertexWarning { return p.warnings } -func NewPrinter(ctx context.Context, out console.File, mode string) *Printer { +func NewPrinter(ctx context.Context, w io.Writer, out console.File, mode string) *Printer { statusCh := make(chan *client.SolveStatus) doneCh := make(chan struct{}) @@ -56,7 +56,6 @@ func NewPrinter(ctx context.Context, out console.File, mode string) *Printer { go func() { var c console.Console - var w io.Writer = out switch mode { case PrinterModeQuiet: w = ioutil.Discard