MCPcopy Create free account
hub / github.com/docker/cli / convertHealthcheck

Function convertHealthcheck

cli/compose/convert/service.go:433–472  ·  view source on GitHub ↗
(healthcheck *composetypes.HealthCheckConfig)

Source from the content-addressed store, hash-verified

431}
432
433func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {
434 if healthcheck == nil {
435 return nil, nil
436 }
437 var (
438 timeout, interval, startPeriod, startInterval time.Duration
439 retries int
440 )
441 if healthcheck.Disable {
442 if len(healthcheck.Test) != 0 {
443 return nil, errors.New("test and disable can't be set at the same time")
444 }
445 return &container.HealthConfig{
446 Test: []string{"NONE"},
447 }, nil
448 }
449 if healthcheck.Timeout != nil {
450 timeout = time.Duration(*healthcheck.Timeout)
451 }
452 if healthcheck.Interval != nil {
453 interval = time.Duration(*healthcheck.Interval)
454 }
455 if healthcheck.StartPeriod != nil {
456 startPeriod = time.Duration(*healthcheck.StartPeriod)
457 }
458 if healthcheck.StartInterval != nil {
459 startInterval = time.Duration(*healthcheck.StartInterval)
460 }
461 if healthcheck.Retries != nil {
462 retries = int(*healthcheck.Retries)
463 }
464 return &container.HealthConfig{
465 Test: healthcheck.Test,
466 Timeout: timeout,
467 Interval: interval,
468 Retries: retries,
469 StartPeriod: startPeriod,
470 StartInterval: startInterval,
471 }, nil
472}
473
474// convertRestartPolicy converts the service's restart-policy. It prefers
475// service.deploy.restart_policy, but falls back to parsing the legacy

Callers 4

TestConvertHealthcheckFunction · 0.85
ServiceFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestConvertHealthcheckFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…