Skip to content
Snippets Groups Projects
Commit 64bd0354730c authored by steeve.chailloux's avatar steeve.chailloux
Browse files

hydrate: strip tailing carriage return on multiline string

parent 0737fe51af44
No related branches found
No related tags found
1 merge request!4Few updates from downstream
...@@ -174,6 +174,46 @@ ...@@ -174,6 +174,46 @@
) )
} }
func TestHydrateRawString(t *testing.T) {
rawVariables := []byte(`
---
foo: |
{"something": "special"}
`)
variables := make(map[string]interface{})
byteContent := bytes.NewReader(rawVariables)
decoder := yaml.NewDecoder(byteContent)
require.NoError(t, decoder.Decode(&variables))
input := `
---
foo: |
{
"bar": <[foo]>,
"answer": 42
}
`
expected := `
---
foo: |
{
"bar": {"something": "special"},
"answer": 42
}
`
buf := bytes.NewBufferString("")
err := runner.Hydrate([]byte(input), buf, variables)
require.NoError(t, err)
assert.Equal(
t,
expected,
buf.String(),
)
fmt.Println("done")
}
func TestYttBuildArgs(t *testing.T) { func TestYttBuildArgs(t *testing.T) {
tl := testutils.NewTestLogger(t) tl := testutils.NewTestLogger(t)
testNS := "environments/ns1" testNS := "environments/ns1"
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
} }
switch v := val.(type) { switch v := val.(type) {
case string: case string:
return w.Write([]byte(v)) return w.Write([]byte(strings.TrimSuffix(v, "\n")))
default: default:
e := yaml.NewEncoder(w) e := yaml.NewEncoder(w)
err := e.Encode(val) err := e.Encode(val)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment