mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 18:10:59 +00:00
Merge pull request #2818 from monopole/hoserFace
Use yaml.IsYNodeString
This commit is contained in:
@@ -66,8 +66,7 @@ func updateNodeValue(node *yaml.Node, newValue interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f Filter) setScalar(node *yaml.RNode) error {
|
func (f Filter) setScalar(node *yaml.RNode) error {
|
||||||
if node.YNode().Kind != yaml.ScalarNode || node.YNode().Tag != yaml.NodeTagString {
|
if !yaml.IsYNodeString(node.YNode()) {
|
||||||
// Only process string values
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
v := expansion2.Expand(node.YNode().Value, f.MappingFunc)
|
v := expansion2.Expand(node.YNode().Value, f.MappingFunc)
|
||||||
@@ -78,11 +77,10 @@ func (f Filter) setScalar(node *yaml.RNode) error {
|
|||||||
func (f Filter) setMap(node *yaml.RNode) error {
|
func (f Filter) setMap(node *yaml.RNode) error {
|
||||||
contents := node.YNode().Content
|
contents := node.YNode().Content
|
||||||
for i := 0; i < len(contents); i += 2 {
|
for i := 0; i < len(contents); i += 2 {
|
||||||
if contents[i].Kind != yaml.ScalarNode || contents[i].Tag != yaml.NodeTagString {
|
if !yaml.IsYNodeString(contents[i]) {
|
||||||
return fmt.Errorf("invalid map key: %s, type: %s", contents[i].Value, contents[i].Tag)
|
return fmt.Errorf("invalid map key: %s, type: %s", contents[i].Value, contents[i].Tag)
|
||||||
}
|
}
|
||||||
if contents[i+1].Kind != yaml.ScalarNode || contents[i+1].Tag != yaml.NodeTagString {
|
if !yaml.IsYNodeString(contents[i+1]) {
|
||||||
// value is not a string
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newValue := expansion2.Expand(contents[i+1].Value, f.MappingFunc)
|
newValue := expansion2.Expand(contents[i+1].Value, f.MappingFunc)
|
||||||
@@ -93,8 +91,7 @@ func (f Filter) setMap(node *yaml.RNode) error {
|
|||||||
|
|
||||||
func (f Filter) setSeq(node *yaml.RNode) error {
|
func (f Filter) setSeq(node *yaml.RNode) error {
|
||||||
for _, item := range node.YNode().Content {
|
for _, item := range node.YNode().Content {
|
||||||
if item.Kind != yaml.ScalarNode || item.Tag != yaml.NodeTagString {
|
if !yaml.IsYNodeString(item) {
|
||||||
// value is not a string
|
|
||||||
return fmt.Errorf("invalid value type expect a string")
|
return fmt.Errorf("invalid value type expect a string")
|
||||||
}
|
}
|
||||||
newValue := expansion2.Expand(item.Value, f.MappingFunc)
|
newValue := expansion2.Expand(item.Value, f.MappingFunc)
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ func IsEmpty(node *RNode) bool {
|
|||||||
|
|
||||||
// IsEmptyMap returns true if the RNode is an empty node or an empty map
|
// IsEmptyMap returns true if the RNode is an empty node or an empty map
|
||||||
func IsEmptyMap(node *RNode) bool {
|
func IsEmptyMap(node *RNode) bool {
|
||||||
if IsEmpty(node) {
|
return IsEmpty(node) || IsYNodeEmptyMap(node.YNode())
|
||||||
return true
|
|
||||||
}
|
|
||||||
return IsYNodeEmptyMap(node.YNode())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNil return true if the node is nil, or its underlying YNode is nil.
|
// IsNil return true if the node is nil, or its underlying YNode is nil.
|
||||||
|
|||||||
Reference in New Issue
Block a user