Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit dfba6b8

Browse files
rumplthaJeztah
authored andcommitted
Add interpolation type cast for max_replicas_per_node
Fixes docker-archive-public/docker.app#688 Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> (cherry picked from commit cb29ef6c6d2df8a93d1b03dd4a0af5ccd00d7cbe) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: e3657b0a8c588aac9995b5ec514de404342bed53 Component: cli
1 parent 0dabf1e commit dfba6b8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

components/cli/cli/compose/loader/interpolate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var interpolateTypeCastMapping = map[interp.Path]interp.Cast{
1919
servicePath("deploy", "rollback_config", "parallelism"): toInt,
2020
servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat,
2121
servicePath("deploy", "restart_policy", "max_attempts"): toInt,
22+
servicePath("deploy", "placement", "max_replicas_per_node"): toInt,
2223
servicePath("ports", interp.PathMatchList, "target"): toInt,
2324
servicePath("ports", interp.PathMatchList, "published"): toInt,
2425
servicePath("ulimits", interp.PathMatchAll): toInt,

components/cli/cli/compose/loader/loader_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ volumes:
582582

583583
func TestLoadWithInterpolationCastFull(t *testing.T) {
584584
dict, err := ParseYAML([]byte(`
585-
version: "3.7"
585+
version: "3.8"
586586
services:
587587
web:
588588
configs:
@@ -604,6 +604,8 @@ services:
604604
max_failure_ratio: $thefloat
605605
restart_policy:
606606
max_attempts: $theint
607+
placement:
608+
max_replicas_per_node: $theint
607609
ports:
608610
- $theint
609611
- "34567"
@@ -652,7 +654,7 @@ networks:
652654
assert.NilError(t, err)
653655
expected := &types.Config{
654656
Filename: "filename.yml",
655-
Version: "3.7",
657+
Version: "3.8",
656658
Services: []types.ServiceConfig{
657659
{
658660
Name: "web",
@@ -685,6 +687,9 @@ networks:
685687
RestartPolicy: &types.RestartPolicy{
686688
MaxAttempts: uint64Ptr(555),
687689
},
690+
Placement: types.Placement{
691+
MaxReplicas: 555,
692+
},
688693
},
689694
Ports: []types.ServicePortConfig{
690695
{Target: 555, Mode: "ingress", Protocol: "tcp"},

0 commit comments

Comments
 (0)