Using single quote style when setting annotations

Annotations must be strings.  Use single-quote style
so tools don't get confused about the type.
This commit is contained in:
Phillip Wittrock
2019-12-16 17:44:45 -08:00
parent 01105af14d
commit eaaefc128f
12 changed files with 127 additions and 118 deletions

View File

@@ -31,9 +31,13 @@ type AnnotationSetter struct {
}
func (s AnnotationSetter) Filter(rn *RNode) (*RNode, error) {
// some tools get confused about the type if annotations are not quoted
v := NewScalarRNode(s.Value)
v.YNode().Tag = "!!str"
v.YNode().Style = yaml.SingleQuotedStyle
return rn.Pipe(
PathGetter{Path: []string{"metadata", "annotations"}, Create: yaml.MappingNode},
FieldSetter{Name: s.Key, Value: NewScalarRNode(s.Value)})
FieldSetter{Name: s.Key, Value: v})
}
func SetAnnotation(key, value string) AnnotationSetter {