Split mapnode.go and test from types.go

This commit is contained in:
jregan
2020-08-16 13:25:19 -07:00
4 changed files with 91 additions and 79 deletions

View File

@@ -88,42 +88,6 @@ func (f FilterFunc) Filter(object *RNode) (*RNode, error) {
return f(object)
}
// 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
}
type TypeMeta struct {
Kind string
APIVersion string