Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit d0e8ebe

Browse files
authored
Merge pull request #1751 from ndeloof/pull_only_missing
only report pull progress if we have something to pull
2 parents b86ff6b + afa1618 commit d0e8ebe

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

local/compose/pull.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,23 +162,31 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
162162
info.IndexServerAddress = registry.IndexServer
163163
}
164164

165+
var needPull []types.ServiceConfig
166+
for _, service := range project.Services {
167+
if service.Image == "" {
168+
continue
169+
}
170+
switch service.PullPolicy {
171+
case "", types.PullPolicyMissing, types.PullPolicyIfNotPresent:
172+
if _, ok := images[service.Image]; ok {
173+
continue
174+
}
175+
case types.PullPolicyNever, types.PullPolicyBuild:
176+
continue
177+
case types.PullPolicyAlways:
178+
// force pull
179+
}
180+
needPull = append(needPull, service)
181+
}
182+
if len(needPull) == 0 {
183+
return nil
184+
}
185+
165186
return progress.Run(ctx, func(ctx context.Context) error {
166187
w := progress.ContextWriter(ctx)
167188
eg, ctx := errgroup.WithContext(ctx)
168-
for _, service := range project.Services {
169-
if service.Image == "" {
170-
continue
171-
}
172-
switch service.PullPolicy {
173-
case types.PullPolicyMissing, types.PullPolicyIfNotPresent:
174-
if _, ok := images[service.Image]; ok {
175-
continue
176-
}
177-
case types.PullPolicyNever, types.PullPolicyBuild:
178-
continue
179-
case types.PullPolicyAlways:
180-
// force pull
181-
}
189+
for _, service := range needPull {
182190
service := service
183191
eg.Go(func() error {
184192
err := s.pullServiceImage(ctx, service, info, s.configFile, w, quietPull)

0 commit comments

Comments
 (0)