Merge pull request #504 from kunalkushwaha/no-console

--no-progress replaced with --progress
docker-18.09
Tibor Vass 2018-08-29 13:44:51 -07:00 committed by GitHub
commit 17e6416706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 10 deletions

View File

@ -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)
})

View File

@ -36,7 +36,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()
@ -57,7 +57,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()
@ -86,7 +86,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)

View File

@ -2709,7 +2709,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 {