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:
@@ -16,3 +16,8 @@ exclude (
|
|||||||
github.com/russross/blackfriday v2.0.0+incompatible
|
github.com/russross/blackfriday v2.0.0+incompatible
|
||||||
sigs.k8s.io/kustomize/api v0.2.0
|
sigs.k8s.io/kustomize/api v0.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace (
|
||||||
|
sigs.k8s.io/kustomize/api => ../api
|
||||||
|
sigs.k8s.io/kustomize/kyaml => ../kyaml
|
||||||
|
)
|
||||||
|
|||||||
@@ -35,18 +35,18 @@ func IsMissingOrNull(node *RNode) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsEmpty returns true if the RNode is MissingOrNull, or is either a MappingNode with
|
// 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 {
|
func IsEmpty(node *RNode) bool {
|
||||||
if node == nil || node.YNode() == nil || node.YNode().Tag == NullNodeTag {
|
if IsMissingOrNull(node) {
|
||||||
return true
|
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 {
|
if node.YNode().Kind == yaml.MappingNode && len(node.YNode().Content) == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if node.YNode().Kind == yaml.SequenceNode && len(node.YNode().Content) == 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user