From 49c9f7527511b23aa82961538538b86e651cfc02 Mon Sep 17 00:00:00 2001 From: Kunal Kushwaha Date: Fri, 13 Jul 2018 16:26:32 +0900 Subject: [PATCH] --no-progress replaced with --progress this make buildctl build output options same as moby. Signed-off-by: Kunal Kushwaha --- cmd/buildctl/build.go | 22 ++++++++++++++++------ cmd/buildctl/build_test.go | 6 +++--- frontend/dockerfile/dockerfile_test.go | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/cmd/buildctl/build.go b/cmd/buildctl/build.go index 4db13646742a..792615b1f901 100644 --- a/cmd/buildctl/build.go +++ b/cmd/buildctl/build.go @@ -37,9 +37,10 @@ var buildCommand = cli.Command{ Name: "exporter-opt", Usage: "Define custom options for exporter", }, - cli.BoolFlag{ - Name: "no-progress", - Usage: "Don't show interactive progress", + cli.StringFlag{ + Name: "progress", + Usage: "Set type of progress (auto, plain, tty). Use plain to show container output", + Value: "auto", }, cli.StringFlag{ Name: "trace", @@ -233,11 +234,20 @@ func build(clicontext *cli.Context) error { eg.Go(func() error { var c console.Console - if !clicontext.Bool("no-progress") { - if cf, err := console.ConsoleFromFile(os.Stderr); err == nil { - c = cf + progressOpt := clicontext.String("progress") + + switch progressOpt { + case "auto", "tty": + cf, err := console.ConsoleFromFile(os.Stderr) + if err != nil && progressOpt == "tty" { + return err } + c = cf + case "plain": + default: + return errors.Errorf("invalid progress value : %s", progressOpt) } + // not using shared context to not disrupt display but let is finish reporting errors return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, displayCh) }) diff --git a/cmd/buildctl/build_test.go b/cmd/buildctl/build_test.go index de724eb64134..9cf458185c0f 100644 --- a/cmd/buildctl/build_test.go +++ b/cmd/buildctl/build_test.go @@ -35,7 +35,7 @@ func testBuildWithLocalFiles(t *testing.T, sb integration.Sandbox) { rdr, err := marshal(st.Root()) require.NoError(t, err) - cmd := sb.Cmd(fmt.Sprintf("build --no-progress --local src=%s", dir)) + cmd := sb.Cmd(fmt.Sprintf("build --progress=plain --local src=%s", dir)) cmd.Stdin = rdr err = cmd.Run() @@ -56,7 +56,7 @@ func testBuildLocalExporter(t *testing.T, sb integration.Sandbox) { require.NoError(t, err) defer os.RemoveAll(tmpdir) - cmd := sb.Cmd(fmt.Sprintf("build --no-progress --exporter=local --exporter-opt output=%s", tmpdir)) + cmd := sb.Cmd(fmt.Sprintf("build --progress=plain --exporter=local --exporter-opt output=%s", tmpdir)) cmd.Stdin = rdr err = cmd.Run() @@ -85,7 +85,7 @@ func testBuildContainerdExporter(t *testing.T, sb integration.Sandbox) { rdr, err := marshal(st.Root()) require.NoError(t, err) - cmd := sb.Cmd("build --no-progress --exporter=image --exporter-opt name=example.com/moby/imageexporter:test") + cmd := sb.Cmd("build --progress=plain --exporter=image --exporter-opt name=example.com/moby/imageexporter:test") cmd.Stdin = rdr err = cmd.Run() require.NoError(t, err) diff --git a/frontend/dockerfile/dockerfile_test.go b/frontend/dockerfile/dockerfile_test.go index 7d87b95573ca..e5381e52e07e 100644 --- a/frontend/dockerfile/dockerfile_test.go +++ b/frontend/dockerfile/dockerfile_test.go @@ -2634,7 +2634,7 @@ func tmpdir(appliers ...fstest.Applier) (string, error) { func dfCmdArgs(ctx, dockerfile string) (string, string) { traceFile := filepath.Join(os.TempDir(), "trace"+identity.NewID()) - return fmt.Sprintf("build --no-progress --frontend dockerfile.v0 --local context=%s --local dockerfile=%s --trace=%s", ctx, dockerfile, traceFile), traceFile + return fmt.Sprintf("build --progress=plain --frontend dockerfile.v0 --local context=%s --local dockerfile=%s --trace=%s", ctx, dockerfile, traceFile), traceFile } func runShell(dir string, cmds ...string) error {