Skip to content

Commit 625a48d

Browse files
committed
pull to respect pull_policy
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 03aadcc commit 625a48d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/compose/pull.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
5555
info.IndexServerAddress = registry.IndexServer
5656
}
5757

58+
images, err := s.getLocalImagesDigests(ctx, project)
59+
if err != nil {
60+
return err
61+
}
62+
5863
w := progress.ContextWriter(ctx)
5964
eg, ctx := errgroup.WithContext(ctx)
6065

@@ -69,6 +74,26 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
6974
})
7075
continue
7176
}
77+
78+
switch service.PullPolicy {
79+
case types.PullPolicyNever, types.PullPolicyBuild:
80+
w.Event(progress.Event{
81+
ID: service.Name,
82+
Status: progress.Done,
83+
Text: "Skipped",
84+
})
85+
continue
86+
case types.PullPolicyMissing, types.PullPolicyIfNotPresent:
87+
if _, ok := images[service.Image]; ok {
88+
w.Event(progress.Event{
89+
ID: service.Name,
90+
Status: progress.Done,
91+
Text: "Exists",
92+
})
93+
continue
94+
}
95+
}
96+
7297
eg.Go(func() error {
7398
err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false)
7499
if err != nil {

0 commit comments

Comments
 (0)