diff --git a/kustomize/go.mod b/kustomize/go.mod index 39328093c..32113e082 100644 --- a/kustomize/go.mod +++ b/kustomize/go.mod @@ -16,3 +16,8 @@ exclude ( github.com/russross/blackfriday v2.0.0+incompatible sigs.k8s.io/kustomize/api v0.2.0 ) + +replace ( + sigs.k8s.io/kustomize/api => ../api + sigs.k8s.io/kustomize/kyaml => ../kyaml +) diff --git a/kyaml/yaml/types.go b/kyaml/yaml/types.go index 862a0ecc8..46112eeda 100644 --- a/kyaml/yaml/types.go +++ b/kyaml/yaml/types.go @@ -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 }