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

hydrate: strip tailing carriage return on multiline string


Signed-off-by: default avatarSteeve Chailloux <steeve.chailloux@proton.ch>
parent 3e9751f90970
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
tl := testutils.NewTestLogger(t)
testNS := "environments/ns1"
......
......@@ -34,7 +34,7 @@
}
switch v := val.(type) {
case string:
return w.Write([]byte(v))
return w.Write([]byte(strings.TrimSuffix(v, "\n")))
default:
e := yaml.NewEncoder(w)
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