Skip to content

Commit

Permalink
introduce pull --missing flag to only pull images not present in cache
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Sep 7, 2023
1 parent e0f39eb commit 016399f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/compose/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand All @@ -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,
Expand Down

0 comments on commit 016399f

Please sign in to comment.