Merge pull request #1751 from ndeloof/pull_only_missing

only report pull progress if we have something to pull
This commit is contained in:
Nicolas De loof 2021-06-07 20:27:34 +02:00 committed by GitHub
commit d0e8ebef15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 14 deletions

View File

@ -162,23 +162,31 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
info.IndexServerAddress = registry.IndexServer
}
var needPull []types.ServiceConfig
for _, service := range project.Services {
if service.Image == "" {
continue
}
switch service.PullPolicy {
case "", types.PullPolicyMissing, types.PullPolicyIfNotPresent:
if _, ok := images[service.Image]; ok {
continue
}
case types.PullPolicyNever, types.PullPolicyBuild:
continue
case types.PullPolicyAlways:
// force pull
}
needPull = append(needPull, service)
}
if len(needPull) == 0 {
return nil
}
return progress.Run(ctx, func(ctx context.Context) error {
w := progress.ContextWriter(ctx)
eg, ctx := errgroup.WithContext(ctx)
for _, service := range project.Services {
if service.Image == "" {
continue
}
switch service.PullPolicy {
case types.PullPolicyMissing, types.PullPolicyIfNotPresent:
if _, ok := images[service.Image]; ok {
continue
}
case types.PullPolicyNever, types.PullPolicyBuild:
continue
case types.PullPolicyAlways:
// force pull
}
for _, service := range needPull {
service := service
eg.Go(func() error {
err := s.pullServiceImage(ctx, service, info, s.configFile, w, quietPull)