MCPcopy
hub / github.com/docker/compose / mustPull

Function mustPull

pkg/compose/pull.go:351–378  ·  view source on GitHub ↗
(service types.ServiceConfig, images map[string]api.ImageSummary)

Source from the content-addressed store, hash-verified

349}
350
351func mustPull(service types.ServiceConfig, images map[string]api.ImageSummary) (bool, error) {
352 if service.Provider != nil {
353 return false, nil
354 }
355 if service.Image == "" {
356 return false, nil
357 }
358 policy, duration, err := service.GetPullPolicy()
359 if err != nil {
360 return false, err
361 }
362 switch policy {
363 case types.PullPolicyAlways:
364 // force pull
365 return true, nil
366 case types.PullPolicyNever, types.PullPolicyBuild:
367 return false, nil
368 case types.PullPolicyRefresh:
369 img, ok := images[service.Image]
370 if !ok {
371 return true, nil
372 }
373 return time.Now().After(img.LastTagTime.Add(duration)), nil
374 default: // Pull if missing
375 _, ok := images[service.Image]
376 return !ok, nil
377 }
378}
379
380func isServiceImageToBuild(service types.ServiceConfig, services types.Services) bool {
381 if service.Build != nil {

Callers 1

pullRequiredImagesMethod · 0.85

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected