| 479 | } |
| 480 | |
| 481 | func (o *healthCheckOptions) toHealthConfig() (*container.HealthConfig, error) { |
| 482 | var healthConfig *container.HealthConfig |
| 483 | haveHealthSettings := o.cmd != "" || |
| 484 | o.interval.Value() != nil || |
| 485 | o.timeout.Value() != nil || |
| 486 | o.startPeriod.Value() != nil || |
| 487 | o.startInterval.Value() != nil || |
| 488 | o.retries != 0 |
| 489 | if o.noHealthcheck { |
| 490 | if haveHealthSettings { |
| 491 | return nil, fmt.Errorf("--%s conflicts with --health-* options", flagNoHealthcheck) |
| 492 | } |
| 493 | healthConfig = &container.HealthConfig{Test: []string{"NONE"}} |
| 494 | } else if haveHealthSettings { |
| 495 | var test []string |
| 496 | if o.cmd != "" { |
| 497 | test = []string{"CMD-SHELL", o.cmd} |
| 498 | } |
| 499 | var interval, timeout, startPeriod, startInterval time.Duration |
| 500 | if ptr := o.interval.Value(); ptr != nil { |
| 501 | interval = *ptr |
| 502 | } |
| 503 | if ptr := o.timeout.Value(); ptr != nil { |
| 504 | timeout = *ptr |
| 505 | } |
| 506 | if ptr := o.startPeriod.Value(); ptr != nil { |
| 507 | startPeriod = *ptr |
| 508 | } |
| 509 | if ptr := o.startInterval.Value(); ptr != nil { |
| 510 | startInterval = *ptr |
| 511 | } |
| 512 | healthConfig = &container.HealthConfig{ |
| 513 | Test: test, |
| 514 | Interval: interval, |
| 515 | Timeout: timeout, |
| 516 | Retries: o.retries, |
| 517 | StartPeriod: startPeriod, |
| 518 | StartInterval: startInterval, |
| 519 | } |
| 520 | } |
| 521 | return healthConfig, nil |
| 522 | } |
| 523 | |
| 524 | // convertExtraHostsToSwarmHosts converts an array of extra hosts in cli |
| 525 | // |