Skip to content

Commit

Permalink
--no-progress replaced with --progress
Browse files Browse the repository at this point in the history
this make buildctl build output options same as moby.

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
  • Loading branch information
kunalkushwaha committed Aug 23, 2018
1 parent af46188 commit 716bc8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
22 changes: 16 additions & 6 deletions cmd/buildctl/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.New("Invalid progress value")
}

// not using shared context to not disrupt display but let is finish reporting errors
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, displayCh)
})
Expand Down
6 changes: 3 additions & 3 deletions cmd/buildctl/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 716bc8e

Please sign in to comment.