mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Tweak sequence treatment in fieldspecs
This commit is contained in:
@@ -14,10 +14,10 @@ import (
|
||||
|
||||
// typeToTag maps OpenAPI schema types to yaml 1.2 tags
|
||||
var typeToTag = map[string]string{
|
||||
"string": StringTag,
|
||||
"integer": IntTag,
|
||||
"boolean": BoolTag,
|
||||
"number": "!!float",
|
||||
"string": NodeTagString,
|
||||
"integer": NodeTagInt,
|
||||
"boolean": NodeTagBool,
|
||||
"number": NodeTagFloat,
|
||||
}
|
||||
|
||||
// FormatNonStringStyle makes sure that values which parse as non-string values in yaml 1.1
|
||||
|
||||
@@ -114,7 +114,7 @@ var valueToTagMap = func() map[string]string {
|
||||
// https://yaml.org/type/null.html
|
||||
values := []string{"~", "null", "Null", "NULL"}
|
||||
for i := range values {
|
||||
val[values[i]] = "!!null"
|
||||
val[values[i]] = yaml.NodeTagNull
|
||||
}
|
||||
|
||||
// https://yaml.org/type/bool.html
|
||||
@@ -122,7 +122,7 @@ var valueToTagMap = func() map[string]string {
|
||||
"y", "Y", "yes", "Yes", "YES", "true", "True", "TRUE", "on", "On", "ON", "n", "N", "no",
|
||||
"No", "NO", "false", "False", "FALSE", "off", "Off", "OFF"}
|
||||
for i := range values {
|
||||
val[values[i]] = "!!bool"
|
||||
val[values[i]] = yaml.NodeTagBool
|
||||
}
|
||||
|
||||
// https://yaml.org/type/float.html
|
||||
@@ -130,7 +130,7 @@ var valueToTagMap = func() map[string]string {
|
||||
".nan", ".NaN", ".NAN", ".inf", ".Inf", ".INF",
|
||||
"+.inf", "+.Inf", "+.INF", "-.inf", "-.Inf", "-.INF"}
|
||||
for i := range values {
|
||||
val[values[i]] = "!!float"
|
||||
val[values[i]] = yaml.NodeTagFloat
|
||||
}
|
||||
|
||||
return val
|
||||
|
||||
@@ -35,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 = StringTag
|
||||
v.YNode().Tag = NodeTagString
|
||||
v.YNode().Style = yaml.SingleQuotedStyle
|
||||
return rn.Pipe(
|
||||
PathGetter{Path: []string{"metadata", "annotations"}, Create: yaml.MappingNode},
|
||||
@@ -82,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 = StringTag
|
||||
v.YNode().Tag = NodeTagString
|
||||
v.YNode().Style = yaml.SingleQuotedStyle
|
||||
return rn.Pipe(
|
||||
PathGetter{Path: []string{"metadata", "labels"}, Create: yaml.MappingNode},
|
||||
|
||||
@@ -16,9 +16,21 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// NullNodeTag is the tag set for a yaml.Document that contains no data -- e.g. it isn't a
|
||||
// Map, Slice, Document, etc
|
||||
NullNodeTag = "!!null"
|
||||
// NodeTagNull is the tag set for a yaml.Document that contains no data;
|
||||
// e.g. it isn't a Map, Slice, Document, etc
|
||||
NodeTagNull = "!!null"
|
||||
NodeTagFloat = "!!float"
|
||||
NodeTagString = "!!str"
|
||||
NodeTagBool = "!!bool"
|
||||
NodeTagInt = "!!int"
|
||||
NodeTagMap = "!!map"
|
||||
NodeTagEmpty = ""
|
||||
|
||||
// TODO: deprecate these
|
||||
NullNodeTag = NodeTagNull
|
||||
StringTag = NodeTagString
|
||||
BoolTag = NodeTagBool
|
||||
IntTag = NodeTagInt
|
||||
)
|
||||
|
||||
// NullNode returns a RNode point represents a null; value
|
||||
@@ -604,12 +616,6 @@ 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