Set common labels and annotations as strings

This commit is contained in:
Phillip Wittrock
2020-05-13 16:52:44 -07:00
parent 0a8d367633
commit 0866e2a54b
5 changed files with 73 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
for _, k := range keys {
if err := node.PipeE(fsslice.Filter{
FsSlice: f.FsSlice,
SetValue: fsslice.SetEntry(k, f.Annotations[k]),
SetValue: fsslice.SetEntry(k, f.Annotations[k], yaml.StringTag),
CreateKind: yaml.MappingNode, // Annotations are MappingNodes.
}); err != nil {
return nil, err

View File

@@ -123,6 +123,33 @@ a:
},
},
},
"number": {
input: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
annotations:
hero: batman
fiend: riddler
`,
expectedOutput: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
annotations:
hero: batman
fiend: riddler
2: ford
clown: "1"
`,
filter: Filter{Annotations: annoMap{
"clown": "1",
"2": "ford",
}},
},
}
for tn, tc := range testCases {