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

Method ToMobyHealthCheck

pkg/compose/convert.go:43–85  ·  pkg/compose/convert.go::composeService.ToMobyHealthCheck

ToMobyHealthCheck convert into container.HealthConfig

(ctx context.Context, check *compose.HealthCheckConfig)

Source from the content-addressed store, hash-verified

41
42// ToMobyHealthCheck convert into container.HealthConfig
43func (s *composeService) ToMobyHealthCheck(ctx context.Context, check *compose.HealthCheckConfig) (*container.HealthConfig, error) {
44 if check == nil {
45 return nil, nil
46 }
47 var (
48 interval time.Duration
49 timeout time.Duration
50 period time.Duration
51 retries int
52 )
53 if check.Interval != nil {
54 interval = time.Duration(*check.Interval)
55 }
56 if check.Timeout != nil {
57 timeout = time.Duration(*check.Timeout)
58 }
59 if check.StartPeriod != nil {
60 period = time.Duration(*check.StartPeriod)
61 }
62 if check.Retries != nil {
63 retries = int(*check.Retries)
64 }
65 test := check.Test
66 if check.Disable {
67 test = []string{"NONE"}
68 }
69 var startInterval time.Duration
70 if check.StartInterval != nil {
71 startInterval = time.Duration(*check.StartInterval)
72 if check.StartPeriod == nil {
73 // see https://github.com/moby/moby/issues/48874
74 return nil, errors.New("healthcheck.start_interval requires healthcheck.start_period to be set")
75 }
76 }
77 return &container.HealthConfig{
78 Test: test,
79 Interval: interval,
80 Timeout: timeout,
81 StartPeriod: period,
82 StartInterval: startInterval,
83 Retries: retries,
84 }, nil
85}
86
87// ToSeconds convert into seconds
88func ToSeconds(d *compose.Duration) *int {

Callers 1

getCreateConfigsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected