From eaf27d9dfe1f23d314c504bc71406d89d4908285 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Mon, 24 Oct 2022 11:04:44 +0200 Subject: [PATCH] map deploy.restart_policy.condition to engine values Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- pkg/compose/create.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index 9a57915ee..019c44605 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -488,13 +488,27 @@ func getRestartPolicy(service types.ServiceConfig) container.RestartPolicy { attempts = int(*policy.MaxAttempts) } restart = container.RestartPolicy{ - Name: policy.Condition, + Name: mapRestartPolicyCondition(policy.Condition), MaximumRetryCount: attempts, } } return restart } +func mapRestartPolicyCondition(condition string) string { + // map definitions of deploy.restart_policy to engine definitions + switch condition { + case "none", "no": + return "no" + case "on-failure", "unless-stopped": + return condition + case "any", "always": + return "always" + default: + return condition + } +} + func getDeployResources(s types.ServiceConfig) container.Resources { var swappiness *int64 if s.MemSwappiness != 0 {