Quote yaml 1.1 non-string values for commonlabels and commonAnnotations

This commit is contained in:
Phillip Wittrock
2020-05-14 19:05:41 -07:00
parent 6837d1f196
commit b622306ff7
3 changed files with 90 additions and 6 deletions

View File

@@ -326,6 +326,50 @@ metadata:
},
},
},
// test quoting of values which are not considered strings in yaml 1.1
"yaml_1_1_compatibility": {
input: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
labels:
hero: batman
fiend: riddler
`,
expectedOutput: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
labels:
hero: batman
fiend: riddler
a: "y"
b: y1
c: "yes"
d: yes1
e: "true"
f: true1
`,
filter: Filter{
Labels: labelMap{
"a": "y",
"b": "y1",
"c": "yes",
"d": "yes1",
"e": "true",
"f": "true1",
},
FsSlice: []types.FieldSpec{
{
Path: "metadata/labels",
CreateIfNotPresent: true,
},
},
},
},
}
for tn, tc := range testCases {