| 349 | } |
| 350 | |
| 351 | func 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 | |
| 380 | func isServiceImageToBuild(service types.ServiceConfig, services types.Services) bool { |
| 381 | if service.Build != nil { |