Added Swarm Job support to Stack Deploy

Added the support for both `global-job` and `replicated-job` to Docker
stack deploy.

Signed-off-by: ollypom <oppomeroy@gmail.com>
This commit is contained in:
ollypom 2021-01-04 13:07:01 +00:00 committed by Sebastiaan van Stijn
parent 2c9626096d
commit 3997f3431f
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 11 additions and 1 deletions

View File

@ -616,11 +616,21 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error)
serviceMode := swarm.ServiceMode{} serviceMode := swarm.ServiceMode{}
switch mode { switch mode {
case "global-job":
if replicas != nil {
return serviceMode, errors.Errorf("replicas can only be used with replicated or replicated-job mode")
}
serviceMode.GlobalJob = &swarm.GlobalJob{}
case "global": case "global":
if replicas != nil { if replicas != nil {
return serviceMode, errors.Errorf("replicas can only be used with replicated mode") return serviceMode, errors.Errorf("replicas can only be used with replicated or replicated-job mode")
} }
serviceMode.Global = &swarm.GlobalService{} serviceMode.Global = &swarm.GlobalService{}
case "replicated-job":
serviceMode.ReplicatedJob = &swarm.ReplicatedJob{
MaxConcurrent: replicas,
TotalCompletions: replicas,
}
case "replicated", "": case "replicated", "":
serviceMode.Replicated = &swarm.ReplicatedService{Replicas: replicas} serviceMode.Replicated = &swarm.ReplicatedService{Replicas: replicas}
default: default: