fix kyaml issue where dropping Style created issues

dropping the node style creates a compatibility issue where quotes around "on" are dropped
because yaml.v3 interprets it as a string.

other yaml parsers interpret on as a bool value, and parse it as a bool rather than string.

fix: retain the original style so it is kept as quoted.

- fmt: don't drop the styles
- merge2: keep the style when merging elements
- setting a field: if changing the value of a scalar field, retain its style by default
This commit is contained in:
Phillip Wittrock
2019-12-19 15:05:49 -08:00
parent 7e56c2c768
commit 98431f6a00
13 changed files with 147 additions and 85 deletions

View File

@@ -68,13 +68,13 @@ func TestLocalPackageWriter_Write_keepReaderAnnotations(t *testing.T) {
metadata:
annotations:
config.kubernetes.io/index: 0
config.kubernetes.io/path: a/b/a_test.yaml
config.kubernetes.io/path: "a/b/a_test.yaml"
---
c: d # second
metadata:
annotations:
config.kubernetes.io/index: 1
config.kubernetes.io/path: a/b/a_test.yaml
config.kubernetes.io/path: "a/b/a_test.yaml"
`, string(b))
b, err = ioutil.ReadFile(filepath.Join(d, "a", "b", "b_test.yaml"))
@@ -89,7 +89,7 @@ g:
metadata:
annotations:
config.kubernetes.io/index: 0
config.kubernetes.io/path: a/b/b_test.yaml
config.kubernetes.io/path: "a/b/b_test.yaml"
`, string(b))
}