mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Don't consider empty array as "empty"
This commit is contained in:
@@ -35,18 +35,18 @@ func IsMissingOrNull(node *RNode) bool {
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the RNode is MissingOrNull, or is either a MappingNode with
|
||||
// no fields, or a SequenceNode with no elements.
|
||||
// no fields.
|
||||
func IsEmpty(node *RNode) bool {
|
||||
if node == nil || node.YNode() == nil || node.YNode().Tag == NullNodeTag {
|
||||
if IsMissingOrNull(node) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Empty sequence is a special case and temporarily not considered as empty here.
|
||||
// Some users may want to keep empty sequence for compatibility reason.
|
||||
// For example, use JSON 6902 patch.
|
||||
if node.YNode().Kind == yaml.MappingNode && len(node.YNode().Content) == 0 {
|
||||
return true
|
||||
}
|
||||
if node.YNode().Kind == yaml.SequenceNode && len(node.YNode().Content) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user