Explorar o código

map deploy.restart_policy.condition to engine values

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours %!s(int64=3) %!d(string=hai) anos
pai
achega
eaf27d9dfe
Modificáronse 1 ficheiros con 15 adicións e 1 borrados
  1. 15 1
      pkg/compose/create.go

+ 15 - 1
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 {