Skip to content
Snippets Groups Projects
Commit 37f5d4e77864 authored by Florent Aide's avatar Florent Aide
Browse files

fix the hydrate bug on ---

parent f376b5af1490
No related branches found
No related tags found
No related merge requests found
Pipeline #45297 passed
package runner
import (
"bufio"
"bytes"
"crypto/sha256"
"fmt"
......@@ -539,4 +540,25 @@
return err
}
func documentSplitter(input io.Reader) [][]byte {
var output [][]byte
var tmpOut []byte
scanner := bufio.NewScanner(input)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
text := scanner.Bytes()
// if sep is found first flush our buffer
if string(text) == "---" {
// flush buffer
output = append(output, tmpOut)
// initialize new buffer
tmpOut = []byte{}
}
tmpOut = append(tmpOut, text...)
tmpOut = append(tmpOut, []byte("\n")...)
}
output = append(output, tmpOut)
return output
}
func Hydrate(input []byte, output io.Writer, variables map[string]interface{}) error {
......@@ -542,5 +564,6 @@
func Hydrate(input []byte, output io.Writer, variables map[string]interface{}) error {
documents := bytes.Split(input, []byte("---\n"))
// documents := bytes.Split(input, []byte("---\n"))
documents := documentSplitter(bytes.NewReader(input))
// yaml lib ignore leading '---'
// see: https://github.com/go-yaml/yaml/issues/749
// which is an issue for ytt value files
......
......@@ -99,7 +99,7 @@
expected := `
---
foo: 33
bar: |-
bar: |
[section1]
value1 = 1
# ----------
......
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