Merge pull request #51399 from thaJeztah/swarm_enums

api/types/swarm: create types for enum-consts
This commit is contained in:
Sebastiaan van Stijn
2025-11-05 16:33:20 +01:00
committed by GitHub
7 changed files with 64 additions and 28 deletions

View File

@@ -106,18 +106,27 @@ type ReplicatedJob struct {
// This type is deliberately empty.
type GlobalJob struct{}
// FailureAction is the action to perform when updating a service fails.
type FailureAction string
const (
// UpdateFailureActionPause PAUSE
UpdateFailureActionPause = "pause"
UpdateFailureActionPause FailureAction = "pause"
// UpdateFailureActionContinue CONTINUE
UpdateFailureActionContinue = "continue"
UpdateFailureActionContinue FailureAction = "continue"
// UpdateFailureActionRollback ROLLBACK
UpdateFailureActionRollback = "rollback"
UpdateFailureActionRollback FailureAction = "rollback"
)
// UpdateOrder is the order of operations when rolling out or rolling back
// an updated tasks for a service.
type UpdateOrder string
const (
// UpdateOrderStopFirst STOP_FIRST
UpdateOrderStopFirst = "stop-first"
UpdateOrderStopFirst UpdateOrder = "stop-first"
// UpdateOrderStartFirst START_FIRST
UpdateOrderStartFirst = "start-first"
UpdateOrderStartFirst UpdateOrder = "start-first"
)
// UpdateConfig represents the update configuration.
@@ -130,7 +139,7 @@ type UpdateConfig struct {
Delay time.Duration `json:",omitempty"`
// FailureAction is the action to take when an update failures.
FailureAction string `json:",omitempty"`
FailureAction FailureAction `json:",omitempty"`
// Monitor indicates how long to monitor a task for failure after it is
// created. If the task fails by ending up in one of the states
@@ -156,7 +165,7 @@ type UpdateConfig struct {
// Order indicates the order of operations when rolling out an updated
// task. Either the old task is shut down before the new task is
// started, or the new task is started before the old task is shut down.
Order string
Order UpdateOrder
}
// ServiceStatus represents the number of running tasks in a service and the
@@ -198,8 +207,12 @@ type JobStatus struct {
LastExecution time.Time `json:",omitempty"`
}
// RegistryAuthSource defines options for the "registryAuthFrom" query parameter
// on service update.
type RegistryAuthSource string
// Values for RegistryAuthFrom in ServiceUpdateOptions
const (
RegistryAuthFromSpec = "spec"
RegistryAuthFromPreviousSpec = "previous-spec"
RegistryAuthFromSpec RegistryAuthSource = "spec"
RegistryAuthFromPreviousSpec RegistryAuthSource = "previous-spec"
)