MCPcopy Create free account
hub / github.com/docker/compose / getRestartPolicy

Function getRestartPolicy

pkg/compose/create.go:592–617  ·  view source on GitHub ↗
(service types.ServiceConfig)

Source from the content-addressed store, hash-verified

590}
591
592func getRestartPolicy(service types.ServiceConfig) container.RestartPolicy {
593 var restart container.RestartPolicy
594 if service.Restart != "" {
595 name, num, ok := strings.Cut(service.Restart, ":")
596 var attempts int
597 if ok {
598 attempts, _ = strconv.Atoi(num)
599 }
600 restart = container.RestartPolicy{
601 Name: mapRestartPolicyCondition(name),
602 MaximumRetryCount: attempts,
603 }
604 }
605 if service.Deploy != nil && service.Deploy.RestartPolicy != nil {
606 policy := *service.Deploy.RestartPolicy
607 var attempts int
608 if policy.MaxAttempts != nil {
609 attempts = int(*policy.MaxAttempts)
610 }
611 restart = container.RestartPolicy{
612 Name: mapRestartPolicyCondition(policy.Condition),
613 MaximumRetryCount: attempts,
614 }
615 }
616 return restart
617}
618
619func mapRestartPolicyCondition(condition string) container.RestartPolicyMode {
620 // map definitions of deploy.restart_policy to engine definitions

Callers 1

getCreateConfigsMethod · 0.85

Calls 1

Tested by

no test coverage detected