Add interpolation type cast for max_replicas_per_node

Fixes https://github.com/docker/app/issues/688

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit cb29ef6c6d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Djordje Lukic 2019-11-04 14:21:47 +01:00 committed by Sebastiaan van Stijn
parent 99c5edceb4
commit e3657b0a8c
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 8 additions and 2 deletions

View File

@ -19,6 +19,7 @@ var interpolateTypeCastMapping = map[interp.Path]interp.Cast{
servicePath("deploy", "rollback_config", "parallelism"): toInt, servicePath("deploy", "rollback_config", "parallelism"): toInt,
servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat, servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat,
servicePath("deploy", "restart_policy", "max_attempts"): toInt, 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, "target"): toInt,
servicePath("ports", interp.PathMatchList, "published"): toInt, servicePath("ports", interp.PathMatchList, "published"): toInt,
servicePath("ulimits", interp.PathMatchAll): toInt, servicePath("ulimits", interp.PathMatchAll): toInt,

View File

@ -582,7 +582,7 @@ volumes:
func TestLoadWithInterpolationCastFull(t *testing.T) { func TestLoadWithInterpolationCastFull(t *testing.T) {
dict, err := ParseYAML([]byte(` dict, err := ParseYAML([]byte(`
version: "3.7" version: "3.8"
services: services:
web: web:
configs: configs:
@ -604,6 +604,8 @@ services:
max_failure_ratio: $thefloat max_failure_ratio: $thefloat
restart_policy: restart_policy:
max_attempts: $theint max_attempts: $theint
placement:
max_replicas_per_node: $theint
ports: ports:
- $theint - $theint
- "34567" - "34567"
@ -652,7 +654,7 @@ networks:
assert.NilError(t, err) assert.NilError(t, err)
expected := &types.Config{ expected := &types.Config{
Filename: "filename.yml", Filename: "filename.yml",
Version: "3.7", Version: "3.8",
Services: []types.ServiceConfig{ Services: []types.ServiceConfig{
{ {
Name: "web", Name: "web",
@ -685,6 +687,9 @@ networks:
RestartPolicy: &types.RestartPolicy{ RestartPolicy: &types.RestartPolicy{
MaxAttempts: uint64Ptr(555), MaxAttempts: uint64Ptr(555),
}, },
Placement: types.Placement{
MaxReplicas: 555,
},
}, },
Ports: []types.ServicePortConfig{ Ports: []types.ServicePortConfig{
{Target: 555, Mode: "ingress", Protocol: "tcp"}, {Target: 555, Mode: "ingress", Protocol: "tcp"},