From 3efe1902692b54328bc9293127fa4e51fdc6bec6 Mon Sep 17 00:00:00 2001 From: advanceboy Date: Sat, 15 Apr 2023 00:23:10 +0900 Subject: [PATCH] Revival support for legacy boolean from YAML 1.1 and earlier Signed-off-by: advanceboy --- interpolation/interpolation.go | 2 +- loader/loader_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/interpolation/interpolation.go b/interpolation/interpolation.go index befc6f04..f77c19c2 100644 --- a/interpolation/interpolation.go +++ b/interpolation/interpolation.go @@ -72,7 +72,7 @@ func recursiveInterpolate(value interface{}, path Path, opts Options) (interface switch value := value.(type) { case string: newValue, err := opts.Substitute(value, template.Mapping(opts.LookupValue)) - if err != nil || newValue == value { + if err != nil { return value, newPathError(path, err) } caster, ok := opts.getCasterForPath(path) diff --git a/loader/loader_test.go b/loader/loader_test.go index 59902af4..b8dfe7e1 100644 --- a/loader/loader_test.go +++ b/loader/loader_test.go @@ -2126,6 +2126,17 @@ services: assert.ErrorContains(t, err, "services.test.build.ssh must be a mapping") } +func TestLoadLegacyBoolean(t *testing.T) { + actual, err := loadYAML(` +name: load-legacy-boolean +services: + test: + init: yes # used to be a valid YAML bool, removed in YAML 1.2 +`) + assert.NilError(t, err) + assert.Check(t, *actual.Services[0].Init) +} + func TestLoadSSHWithDefaultValueInBuildConfig(t *testing.T) { actual, err := loadYAML(` name: load-ssh-with-default-value-in-build-config