Skip to content

Commit

Permalink
Revival support for legacy boolean from YAML 1.1 and earlier
Browse files Browse the repository at this point in the history
Signed-off-by: advanceboy <[email protected]>
  • Loading branch information
advanceboy committed Apr 14, 2023
1 parent 270da2d commit 3efe190
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interpolation/interpolation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3efe190

Please sign in to comment.