mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add tests for IsTaggedNull, IsYNodeEmptySeq and IsYNodeEmptyMap.
This commit is contained in:
@@ -49,10 +49,6 @@ func IsEmptyMap(node *RNode) bool {
|
||||
return IsMissingOrNull(node) || IsYNodeEmptyMap(node.YNode())
|
||||
}
|
||||
|
||||
func IsNull(node *RNode) bool {
|
||||
return !node.IsNil() && node.YNode().Tag == NodeTagNull
|
||||
}
|
||||
|
||||
func IsFieldEmpty(node *MapNode) bool {
|
||||
if node == nil || node.Value == nil || node.Value.YNode() == nil ||
|
||||
node.Value.YNode().Tag == NodeTagNull {
|
||||
@@ -63,11 +59,16 @@ func IsFieldEmpty(node *MapNode) bool {
|
||||
}
|
||||
|
||||
func IsYNodeEmptyMap(n *yaml.Node) bool {
|
||||
return n.Kind == yaml.MappingNode && len(n.Content) == 0
|
||||
return n != nil && n.Kind == yaml.MappingNode && len(n.Content) == 0
|
||||
}
|
||||
|
||||
// IsYNodeTaggedNull returns true if the node is explicitly tagged Null.
|
||||
func IsYNodeTaggedNull(n *yaml.Node) bool {
|
||||
return n != nil && n.Tag == NodeTagNull
|
||||
}
|
||||
|
||||
func IsYNodeEmptySeq(n *yaml.Node) bool {
|
||||
return n.Kind == yaml.SequenceNode && len(n.Content) == 0
|
||||
return n != nil && n.Kind == yaml.SequenceNode && len(n.Content) == 0
|
||||
}
|
||||
|
||||
// IsYNodeEmptyDoc is true if the node is a Document with no content.
|
||||
@@ -377,6 +378,11 @@ func (rn *RNode) IsNil() bool {
|
||||
return rn == nil || rn.YNode() == nil
|
||||
}
|
||||
|
||||
// IsTaggedNull is true if a non-nil node is explicitly tagged Null.
|
||||
func (rn *RNode) IsTaggedNull() bool {
|
||||
return !rn.IsNil() && IsYNodeTaggedNull(rn.YNode())
|
||||
}
|
||||
|
||||
// GetMeta returns the ResourceMeta for an RNode
|
||||
func (rn *RNode) GetMeta() (ResourceMeta, error) {
|
||||
if IsMissingOrNull(rn) {
|
||||
|
||||
Reference in New Issue
Block a user