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

Commit 982bbfb

Browse files
authored
Merge pull request #2184 from thaJeztah/19.03_backport_fix_max_replicas_per_node_interpolation
[19.03 backport] Add interpolation type cast for max_replicas_per_node Upstream-commit: a7cad2fec22d3b70650373c9251a69f71c773ead Component: cli
2 parents ebf0410 + dfba6b8 commit 982bbfb

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)