mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add function to check is YNode zero
This commit is contained in:
@@ -54,6 +54,18 @@ func IsYNodeString(n *yaml.Node) bool {
|
||||
return n.Kind == yaml.ScalarNode && n.Tag == NodeTagString
|
||||
}
|
||||
|
||||
// IsYNodeZero is true if all the public fields in the Node are empty.
|
||||
// Which means it's not initialized and should be omitted when marshal.
|
||||
// The Node itself has a method IsZero but it is not released
|
||||
// in yaml.v3. https://pkg.go.dev/gopkg.in/yaml.v3#Node.IsZero
|
||||
func IsYNodeZero(n *yaml.Node) bool {
|
||||
// TODO: Change this to use IsZero when it's avaialable.
|
||||
return n != nil && n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" &&
|
||||
n.Anchor == "" && n.Alias == nil && n.Content == nil &&
|
||||
n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" &&
|
||||
n.Line == 0 && n.Column == 0
|
||||
}
|
||||
|
||||
// Parser parses values into configuration.
|
||||
type Parser struct {
|
||||
Kind string `yaml:"kind,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user