Skip to content

Commit f8dae06

Browse files
AnvarUndeloof
authored andcommitted
Add support for COMPOSE_PROGRESS env variable
COMPOSE_PROGRESS variable supports 5 values: - "auto" - detect console capabilities - "tty" - use terminal capability for advanced rendering - "plain" - dump raw events to output - "quiet" - don't display events - "json" - outputs a machine-readable JSON stream Signed-off-by: Anvar Umuraliev <an.umuraliev@gmail.com>
1 parent 955e4ed commit f8dae06

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

pkg/e2e/compose_run_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ func TestLocalComposeRun(t *testing.T) {
170170
assert.Assert(t, strings.Contains(res.Combined(), "Pulled"), res.Combined())
171171
})
172172

173+
t.Run("COMPOSE_PROGRESS quiet", func(t *testing.T) {
174+
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "down", "--remove-orphans", "--rmi", "all")
175+
res.Assert(t, icmd.Success)
176+
177+
cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "run", "backend")
178+
res = icmd.RunCmd(cmd, func(c *icmd.Cmd) {
179+
c.Env = append(c.Env, "COMPOSE_PROGRESS=quiet")
180+
})
181+
assert.Assert(t, !strings.Contains(res.Combined(), "Pull complete"), res.Combined())
182+
assert.Assert(t, !strings.Contains(res.Combined(), "Pulled"), res.Combined())
183+
})
184+
173185
t.Run("--pull", func(t *testing.T) {
174186
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "down", "--remove-orphans", "--rmi", "all")
175187
res.Assert(t, icmd.Success)

pkg/progress/writer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package progress
1919
import (
2020
"context"
2121
"io"
22+
"os"
2223
"sync"
2324

2425
"github.com/docker/cli/cli/streams"
@@ -121,6 +122,9 @@ func NewWriter(ctx context.Context, out *streams.Out, progressTitle string) (Wri
121122
if !ok {
122123
dryRun = false
123124
}
125+
if v, ok := os.LookupEnv("COMPOSE_PROGRESS"); ok && Mode == ModeAuto {
126+
Mode = v
127+
}
124128
if Mode == ModeQuiet {
125129
return quiet{}, nil
126130
}

0 commit comments

Comments
 (0)