func ContainsName(name string) Predicate {
	return func(p *PV) bool {
		return strings.Contains(p.object.GetName(), name)
	}
}
ContainsName is filter function to filter pv's
based on the name
package persistentvolume
import (
	"strings"
	corev1 "k8s.io/api/core/v1"
)
type PV struct {
	object *corev1.PersistentVolume
}
type PVList struct {
	items []*PV
}
func (p *PVList) Len() int {
	return len(p.items)
}
func (p *PVList) ToAPIList() *corev1.PersistentVolumeList {
	plist := &corev1.PersistentVolumeList{}
	for _, pvc := range p.items {
		plist.Items = append(plist.Items, *pvc.object)
	}
	return plist
}
type pvBuildOption func(*PV)
func NewForAPIObject(obj *corev1.PersistentVolume, opts ...pvBuildOption) *PV {
	p := &PV{object: obj}
	for _, o := range opts {
		o(p)
	}
	return p
}
type Predicate func(*PV) bool
func (p *PV) IsNil() bool {
	return p.object == nil
}
func (p *PV) GetPath() string {
	local := p.object.Spec.PersistentVolumeSource.Local
	if local != nil {
		return local.Path
	}
	hostPath := p.object.Spec.PersistentVolumeSource.HostPath
	if hostPath != nil {
		return hostPath.Path
	}
	return ""
}
func (p *PV) GetAffinitedNodeHostname() string {
	nodeAffinity := p.object.Spec.NodeAffinity
	if nodeAffinity == nil {
		return ""
	}
	required := nodeAffinity.Required
	if required == nil {
		return ""
	}
	hostname := ""
	for _, selectorTerm := range required.NodeSelectorTerms {
		for _, expression := range selectorTerm.MatchExpressions {
			if expression.Key == KeyNode &&
				expression.Operator == corev1.NodeSelectorOpIn {
				if len(expression.Values) != 1 {
					return ""
				}
				hostname = expression.Values[0]
				break
			}
		}
		if hostname != "" {
			break
		}
	}
	return hostname
}
func IsNil() Predicate {
	return func(p *PV) bool {
		return p.IsNil()
	}
}