From e3657b0a8c588aac9995b5ec514de404342bed53 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Mon, 4 Nov 2019 14:21:47 +0100 Subject: [PATCH] Add interpolation type cast for max_replicas_per_node Fixes https://github.com/docker/app/issues/688 Signed-off-by: Djordje Lukic (cherry picked from commit cb29ef6c6d2df8a93d1b03dd4a0af5ccd00d7cbe) Signed-off-by: Sebastiaan van Stijn --- cli/compose/loader/interpolate.go | 1 + cli/compose/loader/loader_test.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/compose/loader/interpolate.go b/cli/compose/loader/interpolate.go index f0a321fc49..d25936be86 100644 --- a/cli/compose/loader/interpolate.go +++ b/cli/compose/loader/interpolate.go @@ -19,6 +19,7 @@ var interpolateTypeCastMapping = map[interp.Path]interp.Cast{ servicePath("deploy", "rollback_config", "parallelism"): toInt, servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat, servicePath("deploy", "restart_policy", "max_attempts"): toInt, + servicePath("deploy", "placement", "max_replicas_per_node"): toInt, servicePath("ports", interp.PathMatchList, "target"): toInt, servicePath("ports", interp.PathMatchList, "published"): toInt, servicePath("ulimits", interp.PathMatchAll): toInt, diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index d956fb9f5f..d91cb9093c 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -582,7 +582,7 @@ volumes: func TestLoadWithInterpolationCastFull(t *testing.T) { dict, err := ParseYAML([]byte(` -version: "3.7" +version: "3.8" services: web: configs: @@ -604,6 +604,8 @@ services: max_failure_ratio: $thefloat restart_policy: max_attempts: $theint + placement: + max_replicas_per_node: $theint ports: - $theint - "34567" @@ -652,7 +654,7 @@ networks: assert.NilError(t, err) expected := &types.Config{ Filename: "filename.yml", - Version: "3.7", + Version: "3.8", Services: []types.ServiceConfig{ { Name: "web", @@ -685,6 +687,9 @@ networks: RestartPolicy: &types.RestartPolicy{ MaxAttempts: uint64Ptr(555), }, + Placement: types.Placement{ + MaxReplicas: 555, + }, }, Ports: []types.ServicePortConfig{ {Target: 555, Mode: "ingress", Protocol: "tcp"},