Merge pull request #1978 from thaJeztah/18.09_backport_fix_rollback_config_interpolation

[18.09 backport] Fix Rollback config type interpolation
This commit is contained in:
Sebastiaan van Stijn
2019-07-03 23:09:20 +02:00
committed by GitHub
2 changed files with 11 additions and 2 deletions

View File

@ -16,6 +16,8 @@ var interpolateTypeCastMapping = map[interp.Path]interp.Cast{
servicePath("deploy", "replicas"): toInt,
servicePath("deploy", "update_config", "parallelism"): toInt,
servicePath("deploy", "update_config", "max_failure_ratio"): toFloat,
servicePath("deploy", "rollback_config", "parallelism"): toInt,
servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat,
servicePath("deploy", "restart_policy", "max_attempts"): toInt,
servicePath("ports", interp.PathMatchList, "target"): toInt,
servicePath("ports", interp.PathMatchList, "published"): toInt,

View File

@ -507,7 +507,7 @@ volumes:
func TestLoadWithInterpolationCastFull(t *testing.T) {
dict, err := ParseYAML([]byte(`
version: "3.4"
version: "3.7"
services:
web:
configs:
@ -524,6 +524,9 @@ services:
update_config:
parallelism: $theint
max_failure_ratio: $thefloat
rollback_config:
parallelism: $theint
max_failure_ratio: $thefloat
restart_policy:
max_attempts: $theint
ports:
@ -574,7 +577,7 @@ networks:
assert.NilError(t, err)
expected := &types.Config{
Filename: "filename.yml",
Version: "3.4",
Version: "3.7",
Services: []types.ServiceConfig{
{
Name: "web",
@ -600,6 +603,10 @@ networks:
Parallelism: uint64Ptr(555),
MaxFailureRatio: 3.14,
},
RollbackConfig: &types.UpdateConfig{
Parallelism: uint64Ptr(555),
MaxFailureRatio: 3.14,
},
RestartPolicy: &types.RestartPolicy{
MaxAttempts: uint64Ptr(555),
},