Skip to content

Commit

Permalink
introduce --ignore-buildable to ignore buildable images on pull
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Jan 3, 2023
1 parent a224780 commit 6d68799
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cmd/compose/pull.go
Expand Up @@ -37,6 +37,7 @@ type pullOptions struct {
noParallel bool
includeDeps bool
ignorePullFailures bool
noBuildable bool
}

func pullCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
Expand All @@ -58,13 +59,14 @@ func pullCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
ValidArgsFunction: completeServiceNames(p),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information")
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information.")
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies.")
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel.")
flags.MarkHidden("parallel") //nolint:errcheck
cmd.Flags().BoolVar(&opts.parallel, "no-parallel", true, "DEPRECATED disable parallel pulling.")
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.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.")
return cmd
}

Expand Down Expand Up @@ -97,7 +99,8 @@ func runPull(ctx context.Context, backend api.Service, opts pullOptions, service
}

return backend.Pull(ctx, project, api.PullOptions{
Quiet: opts.quiet,
IgnoreFailures: opts.ignorePullFailures,
Quiet: opts.quiet,
IgnoreFailures: opts.ignorePullFailures,
IgnoreBuildable: opts.noBuildable,
})
}
5 changes: 3 additions & 2 deletions pkg/api/api.go
Expand Up @@ -193,8 +193,9 @@ type PushOptions struct {

// PullOptions group options of the Pull API
type PullOptions struct {
Quiet bool
IgnoreFailures bool
Quiet bool
IgnoreFailures bool
IgnoreBuildable bool
}

// ImagesOptions group options of the Images API
Expand Down
9 changes: 9 additions & 0 deletions pkg/compose/pull.go
Expand Up @@ -102,6 +102,15 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
}
}

if service.Build != nil && opts.IgnoreBuildable {
w.Event(progress.Event{
ID: service.Name,
Status: progress.Done,
Text: "Skipped - Image can be built",
})
continue
}

if s, ok := imagesBeingPulled[service.Image]; ok {
w.Event(progress.Event{
ID: service.Name,
Expand Down

0 comments on commit 6d68799

Please sign in to comment.