mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user