kustomize transformers to create fields if they are null

This commit is contained in:
Phillip Wittrock
2020-05-15 12:30:59 -07:00
parent dd3a79bcf7
commit 77b5a4a215
11 changed files with 143 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
FsSlice: f.FsSlice,
SetValue: fsslice.SetEntry(k, f.Annotations[k], yaml.StringTag),
CreateKind: yaml.MappingNode, // Annotations are MappingNodes.
CreateTag: "!!map",
}); err != nil {
return nil, err
}

View File

@@ -186,6 +186,30 @@ metadata:
"f": "true1",
}},
},
// test quoting of values which are not considered strings in yaml 1.1
"null_annotations": {
input: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
annotations: null
`,
expectedOutput: `
apiVersion: example.com/v1
kind: Foo
metadata:
name: instance
annotations:
a: a1
b: b1
`,
filter: Filter{Annotations: annoMap{
"a": "a1",
"b": "b1",
}},
},
}
for tn, tc := range testCases {