Skip to content

Commit

Permalink
pull to respect pull_policy
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Apr 12, 2022
1 parent 03aadcc commit 625a48d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/compose/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
info.IndexServerAddress = registry.IndexServer
}

images, err := s.getLocalImagesDigests(ctx, project)
if err != nil {
return err
}

w := progress.ContextWriter(ctx)
eg, ctx := errgroup.WithContext(ctx)

Expand All @@ -69,6 +74,26 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
})
continue
}

switch service.PullPolicy {
case types.PullPolicyNever, types.PullPolicyBuild:
w.Event(progress.Event{
ID: service.Name,
Status: progress.Done,
Text: "Skipped",
})
continue
case types.PullPolicyMissing, types.PullPolicyIfNotPresent:
if _, ok := images[service.Image]; ok {
w.Event(progress.Event{
ID: service.Name,
Status: progress.Done,
Text: "Exists",
})
continue
}
}

eg.Go(func() error {
err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false)
if err != nil {
Expand Down

0 comments on commit 625a48d

Please sign in to comment.