mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #2265 from pwittrock/merge3
Setters: support for setting string list fields
This commit is contained in:
@@ -14,9 +14,9 @@ import (
|
||||
|
||||
// typeToTag maps OpenAPI schema types to yaml 1.2 tags
|
||||
var typeToTag = map[string]string{
|
||||
"string": "!!str",
|
||||
"integer": "!!int",
|
||||
"boolean": "!!bool",
|
||||
"string": StringTag,
|
||||
"integer": IntTag,
|
||||
"boolean": BoolTag,
|
||||
"number": "!!float",
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
package yaml
|
||||
|
||||
import "gopkg.in/yaml.v3"
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// AnnotationClearer removes an annotation at metadata.annotations.
|
||||
// Returns nil if the annotation or field does not exist.
|
||||
@@ -33,7 +35,7 @@ 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().Tag = StringTag
|
||||
v.YNode().Style = yaml.SingleQuotedStyle
|
||||
return rn.Pipe(
|
||||
PathGetter{Path: []string{"metadata", "annotations"}, Create: yaml.MappingNode},
|
||||
@@ -80,7 +82,7 @@ type LabelSetter struct {
|
||||
func (s LabelSetter) Filter(rn *RNode) (*RNode, error) {
|
||||
// some tools get confused about the type if labels are not quoted
|
||||
v := NewScalarRNode(s.Value)
|
||||
v.YNode().Tag = "!!str"
|
||||
v.YNode().Tag = StringTag
|
||||
v.YNode().Style = yaml.SingleQuotedStyle
|
||||
return rn.Pipe(
|
||||
PathGetter{Path: []string{"metadata", "labels"}, Create: yaml.MappingNode},
|
||||
|
||||
@@ -588,6 +588,12 @@ func (rn *RNode) VisitFields(fn func(node *MapNode) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
StringTag = "!!str"
|
||||
BoolTag = "!!bool"
|
||||
IntTag = "!!int"
|
||||
)
|
||||
|
||||
// Elements returns the list of elements in the RNode.
|
||||
// Returns an error for non-SequenceNodes.
|
||||
func (rn *RNode) Elements() ([]*RNode, error) {
|
||||
|
||||
Reference in New Issue
Block a user