From 3997f3431f479475f92dab1612abe2f99a0ab8d7 Mon Sep 17 00:00:00 2001 From: ollypom Date: Mon, 4 Jan 2021 13:07:01 +0000 Subject: [PATCH] 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 --- cli/compose/convert/service.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index b0095f19be..aa1cd36b63 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -616,11 +616,21 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error) serviceMode := swarm.ServiceMode{} 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": 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{} + case "replicated-job": + serviceMode.ReplicatedJob = &swarm.ReplicatedJob{ + MaxConcurrent: replicas, + TotalCompletions: replicas, + } case "replicated", "": serviceMode.Replicated = &swarm.ReplicatedService{Replicas: replicas} default: