Browse code

api/types/swarm: define type for UpdateOrder

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/11/05 19:37:15
Showing 3 changed files
... ...
@@ -118,11 +118,15 @@ const (
118 118
 	UpdateFailureActionRollback FailureAction = "rollback"
119 119
 )
120 120
 
121
+// UpdateOrder is the order of operations when rolling out or rolling back
122
+// an updated tasks for a service.
123
+type UpdateOrder string
124
+
121 125
 const (
122 126
 	// UpdateOrderStopFirst STOP_FIRST
123
-	UpdateOrderStopFirst = "stop-first"
127
+	UpdateOrderStopFirst UpdateOrder = "stop-first"
124 128
 	// UpdateOrderStartFirst START_FIRST
125
-	UpdateOrderStartFirst = "start-first"
129
+	UpdateOrderStartFirst UpdateOrder = "start-first"
126 130
 )
127 131
 
128 132
 // UpdateConfig represents the update configuration.
... ...
@@ -161,7 +165,7 @@ type UpdateConfig struct {
161 161
 	// Order indicates the order of operations when rolling out an updated
162 162
 	// task. Either the old task is shut down before the new task is
163 163
 	// started, or the new task is started before the old task is shut down.
164
-	Order string
164
+	Order UpdateOrder
165 165
 }
166 166
 
167 167
 // ServiceStatus represents the number of running tasks in a service and the
... ...
@@ -678,7 +678,7 @@ func setInstances(replicas int) testdaemon.ServiceConstructor {
678 678
 	}
679 679
 }
680 680
 
681
-func setUpdateOrder(order string) testdaemon.ServiceConstructor {
681
+func setUpdateOrder(order swarm.UpdateOrder) testdaemon.ServiceConstructor {
682 682
 	return func(s *swarm.Service) {
683 683
 		if s.Spec.UpdateConfig == nil {
684 684
 			s.Spec.UpdateConfig = &swarm.UpdateConfig{}
... ...
@@ -687,7 +687,7 @@ func setUpdateOrder(order string) testdaemon.ServiceConstructor {
687 687
 	}
688 688
 }
689 689
 
690
-func setRollbackOrder(order string) testdaemon.ServiceConstructor {
690
+func setRollbackOrder(order swarm.UpdateOrder) testdaemon.ServiceConstructor {
691 691
 	return func(s *swarm.Service) {
692 692
 		if s.Spec.RollbackConfig == nil {
693 693
 			s.Spec.RollbackConfig = &swarm.UpdateConfig{}
... ...
@@ -118,11 +118,15 @@ const (
118 118
 	UpdateFailureActionRollback FailureAction = "rollback"
119 119
 )
120 120
 
121
+// UpdateOrder is the order of operations when rolling out or rolling back
122
+// an updated tasks for a service.
123
+type UpdateOrder string
124
+
121 125
 const (
122 126
 	// UpdateOrderStopFirst STOP_FIRST
123
-	UpdateOrderStopFirst = "stop-first"
127
+	UpdateOrderStopFirst UpdateOrder = "stop-first"
124 128
 	// UpdateOrderStartFirst START_FIRST
125
-	UpdateOrderStartFirst = "start-first"
129
+	UpdateOrderStartFirst UpdateOrder = "start-first"
126 130
 )
127 131
 
128 132
 // UpdateConfig represents the update configuration.
... ...
@@ -161,7 +165,7 @@ type UpdateConfig struct {
161 161
 	// Order indicates the order of operations when rolling out an updated
162 162
 	// task. Either the old task is shut down before the new task is
163 163
 	// started, or the new task is started before the old task is shut down.
164
-	Order string
164
+	Order UpdateOrder
165 165
 }
166 166
 
167 167
 // ServiceStatus represents the number of running tasks in a service and the