Browse code

Use "on-failure" for both containers and services

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/07/07 18:32:19
Showing 9 changed files
... ...
@@ -476,7 +476,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
476 476
 
477 477
 	flags.Var(&opts.replicas, flagReplicas, "Number of tasks")
478 478
 
479
-	flags.StringVar(&opts.restartPolicy.condition, flagRestartCondition, "", "Restart when condition is met (none, on_failure, or any)")
479
+	flags.StringVar(&opts.restartPolicy.condition, flagRestartCondition, "", "Restart when condition is met (none, on-failure, or any)")
480 480
 	flags.Var(&opts.restartPolicy.delay, flagRestartDelay, "Delay between restart attempts")
481 481
 	flags.Var(&opts.restartPolicy.maxAttempts, flagRestartMaxAttempts, "Maximum number of restarts before giving up")
482 482
 	flags.Var(&opts.restartPolicy.window, flagRestartWindow, "Window used to evaluate the restart policy")
... ...
@@ -1701,7 +1701,7 @@ _docker_service_update() {
1701 1701
 			return
1702 1702
 			;;
1703 1703
 		--restart-condition)
1704
-			COMPREPLY=( $( compgen -W "any none on_failure" -- "$cur" ) )
1704
+			COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) )
1705 1705
 			return
1706 1706
 			;;
1707 1707
 		--user|-u)
... ...
@@ -1079,7 +1079,7 @@ __docker_service_subcommand() {
1079 1079
         "($help)--replicas=[Number of tasks]:replicas: "
1080 1080
         "($help)--reserve-cpu=[Reserve CPUs]:value: "
1081 1081
         "($help)--reserve-memory=[Reserve Memory]:value: "
1082
-        "($help)--restart-condition=[Restart when condition is met]:mode:(any none on_failure)"
1082
+        "($help)--restart-condition=[Restart when condition is met]:mode:(any none on-failure)"
1083 1083
         "($help)--restart-delay=[Delay between restart attempts]:delay: "
1084 1084
         "($help)--restart-max-attempts=[Maximum number of restarts before giving up]:max-attempts: "
1085 1085
         "($help)--restart-window=[Window used to evaluate the restart policy]:window: "
... ...
@@ -219,7 +219,8 @@ func restartPolicyToGRPC(p *types.RestartPolicy) (*swarmapi.RestartPolicy, error
219 219
 	var rp *swarmapi.RestartPolicy
220 220
 	if p != nil {
221 221
 		rp = &swarmapi.RestartPolicy{}
222
-		if condition, ok := swarmapi.RestartPolicy_RestartCondition_value[strings.ToUpper(string(p.Condition))]; ok {
222
+		sanatizedCondition := strings.ToUpper(strings.Replace(string(p.Condition), "-", "_", -1))
223
+		if condition, ok := swarmapi.RestartPolicy_RestartCondition_value[sanatizedCondition]; ok {
223 224
 			rp.Condition = swarmapi.RestartPolicy_RestartCondition(condition)
224 225
 		} else if string(p.Condition) == "" {
225 226
 			rp.Condition = swarmapi.RestartOnAny
... ...
@@ -4007,7 +4007,7 @@ JSON Parameters:
4007 4007
             - **Memory** – Memory reservation
4008 4008
     - **RestartPolicy** – Specification for the restart policy which applies to containers created
4009 4009
       as part of this service.
4010
-        - **Condition** – Condition for restart (`none`, `on_failure`, or `any`).
4010
+        - **Condition** – Condition for restart (`none`, `on-failure`, or `any`).
4011 4011
         - **Delay** – Delay between restart attempts.
4012 4012
         - **Attempts** – Maximum attempts to restart a given container before giving up (default value
4013 4013
           is 0, which is ignored).
... ...
@@ -4225,7 +4225,7 @@ Update the service `id`.
4225 4225
             - **Memory** – Memory reservation
4226 4226
     - **RestartPolicy** – Specification for the restart policy which applies to containers created
4227 4227
       as part of this service.
4228
-        - **Condition** – Condition for restart (`none`, `on_failure`, or `any`).
4228
+        - **Condition** – Condition for restart (`none`, `on-failure`, or `any`).
4229 4229
         - **Delay** – Delay between restart attempts.
4230 4230
         - **Attempts** – Maximum attempts to restart a given container before giving up (default value
4231 4231
           is 0, which is ignored).
... ...
@@ -4008,7 +4008,7 @@ JSON Parameters:
4008 4008
             - **Memory** – Memory reservation
4009 4009
     - **RestartPolicy** – Specification for the restart policy which applies to containers created
4010 4010
       as part of this service.
4011
-        - **Condition** – Condition for restart (`none`, `on_failure`, or `any`).
4011
+        - **Condition** – Condition for restart (`none`, `on-failure`, or `any`).
4012 4012
         - **Delay** – Delay between restart attempts.
4013 4013
         - **Attempts** – Maximum attempts to restart a given container before giving up (default value
4014 4014
           is 0, which is ignored).
... ...
@@ -4226,7 +4226,7 @@ Update the service `id`.
4226 4226
             - **Memory** – Memory reservation
4227 4227
     - **RestartPolicy** – Specification for the restart policy which applies to containers created
4228 4228
       as part of this service.
4229
-        - **Condition** – Condition for restart (`none`, `on_failure`, or `any`).
4229
+        - **Condition** – Condition for restart (`none`, `on-failure`, or `any`).
4230 4230
         - **Delay** – Delay between restart attempts.
4231 4231
         - **Attempts** – Maximum attempts to restart a given container before giving up (default value
4232 4232
           is 0, which is ignored).
... ...
@@ -32,7 +32,7 @@ Options:
32 32
       --replicas value               Number of tasks (default none)
33 33
       --reserve-cpu value            Reserve CPUs (default 0.000)
34 34
       --reserve-memory value         Reserve Memory (default 0 B)
35
-      --restart-condition string     Restart when condition is met (none, on_failure, or any)
35
+      --restart-condition string     Restart when condition is met (none, on-failure, or any)
36 36
       --restart-delay value          Delay between restart attempts (default none)
37 37
       --restart-max-attempts value   Maximum number of restarts before giving up (default none)
38 38
       --restart-window value         Window used to evaluate the restart policy (default none)
... ...
@@ -35,7 +35,7 @@ Options:
35 35
       --replicas value               Number of tasks (default none)
36 36
       --reserve-cpu value            Reserve CPUs (default 0.000)
37 37
       --reserve-memory value         Reserve Memory (default 0 B)
38
-      --restart-condition string     Restart when condition is met (none, on_failure, or any)
38
+      --restart-condition string     Restart when condition is met (none, on-failure, or any)
39 39
       --restart-delay value          Delay between restart attempts (default none)
40 40
       --restart-max-attempts value   Maximum number of restarts before giving up (default none)
41 41
       --restart-window value         Window used to evaluate the restart policy (default none)
... ...
@@ -93,7 +93,7 @@ const (
93 93
 	// RestartPolicyConditionNone NONE
94 94
 	RestartPolicyConditionNone RestartPolicyCondition = "none"
95 95
 	// RestartPolicyConditionOnFailure ON_FAILURE
96
-	RestartPolicyConditionOnFailure RestartPolicyCondition = "on_failure"
96
+	RestartPolicyConditionOnFailure RestartPolicyCondition = "on-failure"
97 97
 	// RestartPolicyConditionAny ANY
98 98
 	RestartPolicyConditionAny RestartPolicyCondition = "any"
99 99
 )