From 016399f97c313126b29f6a99b8603de64a292ef3 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 7 Sep 2023 16:36:22 +0200 Subject: [PATCH] introduce pull --missing flag to only pull images not present in cache Signed-off-by: Nicolas De Loof --- cmd/compose/pull.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/compose/pull.go b/cmd/compose/pull.go index 5b0af8e12dc..7398d510a51 100644 --- a/cmd/compose/pull.go +++ b/cmd/compose/pull.go @@ -38,6 +38,7 @@ type pullOptions struct { includeDeps bool ignorePullFailures bool noBuildable bool + missing bool } func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command { @@ -67,6 +68,7 @@ func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) flags.MarkHidden("no-parallel") //nolint:errcheck cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures.") cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built.") + cmd.Flags().BoolVar(&opts.missing, "missing", false, "Only pull images that are not present in local cache.") return cmd } @@ -83,6 +85,13 @@ func runPull(ctx context.Context, dockerCli command.Cli, backend api.Service, op } } + if opts.missing { + for i, service := range project.Services { + service.PullPolicy = types.PullPolicyMissing + project.Services[i] = service + } + } + return backend.Pull(ctx, project, api.PullOptions{ Quiet: opts.quiet, IgnoreFailures: opts.ignorePullFailures,