From 94246f3cac5549d77abfe65c6cda14d519c3a2e7 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:51:13 +0100 Subject: [PATCH] pass QuietOption when starting dependencies from run command Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- cmd/compose/run.go | 11 ++++++----- pkg/e2e/compose_run_test.go | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/compose/run.go b/cmd/compose/run.go index 180326852..b4a5da365 100644 --- a/cmd/compose/run.go +++ b/cmd/compose/run.go @@ -231,7 +231,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op } buildForDeps = &bo } - return startDependencies(ctx, backend, *project, buildForDeps, options.Service, options.ignoreOrphans) + return startDependencies(ctx, backend, *project, buildForDeps, options) }, dockerCli.Err()) if err != nil { return err @@ -298,11 +298,11 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op return err } -func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, requestedServiceName string, ignoreOrphans bool) error { +func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, options runOptions) error { dependencies := types.Services{} var requestedService types.ServiceConfig for name, service := range project.Services { - if name != requestedServiceName { + if name != options.Service { dependencies[name] = service } else { requestedService = service @@ -310,10 +310,11 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P } project.Services = dependencies - project.DisabledServices[requestedServiceName] = requestedService + project.DisabledServices[options.Service] = requestedService err := backend.Create(ctx, &project, api.CreateOptions{ Build: buildOpts, - IgnoreOrphans: ignoreOrphans, + IgnoreOrphans: options.ignoreOrphans, + QuietPull: options.quietPull, }) if err != nil { return err diff --git a/pkg/e2e/compose_run_test.go b/pkg/e2e/compose_run_test.go index b074e6a80..e552e4653 100644 --- a/pkg/e2e/compose_run_test.go +++ b/pkg/e2e/compose_run_test.go @@ -160,4 +160,13 @@ func TestLocalComposeRun(t *testing.T) { c.RunDockerComposeCmd(t, "-f", "./fixtures/dependencies/deps-not-required.yaml", "down", "--remove-orphans") }) + + t.Run("--quiet-pull", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "down", "--rmi", "all") + res.Assert(t, icmd.Success) + + res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "run", "--quiet-pull", "back") + assert.Assert(t, !strings.Contains(res.Combined(), "Pull complete"), res.Combined()) + assert.Assert(t, strings.Contains(res.Combined(), "Pulled"), res.Combined()) + }) }