Skip to content

Commit

Permalink
Handle multi-document YAML streams
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson committed Nov 13, 2019
1 parent 4856ec1 commit c9eb790
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestUnmarshalArray(t *testing.T) {
assert.EqualValues(t, expected, actual)
}
test(JSONArray(`["foo","bar",{"baz":{"qux": true},"quux":{"42":18},"corge":{"false":"blah"}}]`))
test(YAMLArray(`
test(YAMLArray(`---
- foo
- bar
- baz:
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/datasources_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ FOO.BAR = "values can be double-quoted, and shell\nescapes are supported"
BAZ = "variable expansion: ${FOO}"
QUX='single quotes ignore $variables'
`,
"multidoc.yaml": `---
# empty document
---
foo: bar
---
foo: baz
...
`,
}),
fs.WithDir("sortorder", fs.WithFiles(map[string]string{
Expand Down Expand Up @@ -185,4 +193,12 @@ bar`})
"FOO.BAR": "values can be double-quoted, and shell\nescapes are supported",
"QUX": "single quotes ignore $variables"
}`})

result = icmd.RunCmd(icmd.Command(GomplateBin,
"-c=multidoc.yaml",
"-i", `{{ .multidoc.foo }}`,
), func(c *icmd.Cmd) {
c.Dir = s.tmpDir.Path()
})
result.Assert(c, icmd.Expected{ExitCode: 0, Out: "bar"})
}

0 comments on commit c9eb790

Please sign in to comment.