k3s/vendor/sigs.k8s.io/kustomize/kyaml/yaml/mapnode.go
Brad Davidson e8381db778 Update Kubernetes to v1.21.0
* Update Kubernetes to v1.21.0
* Update to golang v1.16.2
* Update dependent modules to track with upstream
* Switch to upstream flannel
* Track changes to upstream cloud-controller-manager and FeatureGates

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2021-04-14 14:51:42 -07:00

41 lines
774 B
Go

// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package yaml
// MapNode wraps a field key and value.
type MapNode struct {
Key *RNode
Value *RNode
}
// IsNilOrEmpty returns true if the MapNode is nil,
// has no value, or has a value that appears empty.
func (mn *MapNode) IsNilOrEmpty() bool {
return mn == nil || mn.Value.IsNilOrEmpty()
}
type MapNodeSlice []*MapNode
func (m MapNodeSlice) Keys() []*RNode {
var keys []*RNode
for i := range m {
if m[i] != nil {
keys = append(keys, m[i].Key)
}
}
return keys
}
func (m MapNodeSlice) Values() []*RNode {
var values []*RNode
for i := range m {
if m[i] != nil {
values = append(values, m[i].Value)
} else {
values = append(values, nil)
}
}
return values
}