diff --git a/runner/config_test.go b/runner/config_test.go index 0737fe51af44636a6e42345f445eaf475778965a_cnVubmVyL2NvbmZpZ190ZXN0Lmdv..64bd0354730c273189647b4aca0f0379122ef440_cnVubmVyL2NvbmZpZ190ZXN0Lmdv 100644 --- a/runner/config_test.go +++ b/runner/config_test.go @@ -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" diff --git a/runner/hydrate.go b/runner/hydrate.go index 0737fe51af44636a6e42345f445eaf475778965a_cnVubmVyL2h5ZHJhdGUuZ28=..64bd0354730c273189647b4aca0f0379122ef440_cnVubmVyL2h5ZHJhdGUuZ28= 100644 --- a/runner/hydrate.go +++ b/runner/hydrate.go @@ -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)