(service types.ServiceConfig)
| 590 | } |
| 591 | |
| 592 | func 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 | |
| 619 | func mapRestartPolicyCondition(condition string) container.RestartPolicyMode { |
| 620 | // map definitions of deploy.restart_policy to engine definitions |
no test coverage detected