func NodeSelectorRequirementsAsFieldSelector(nsm []v1.NodeSelectorRequirement) (fields.Selector, error) {
	if len(nsm) == 0 {
		return fields.Nothing(), nil
	}

	selectors := []fields.Selector{}
	for _, expr := range nsm {
		switch expr.Operator {
		case v1.NodeSelectorOpIn:
			if len(expr.Values) != 1 {
				return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
					len(expr.Values), expr.Operator)
			}
			selectors = append(selectors, fields.OneTermEqualSelector(expr.Key, expr.Values[0]))

		case v1.NodeSelectorOpNotIn:
			if len(expr.Values) != 1 {
				return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
					len(expr.Values), expr.Operator)
			}
			selectors = append(selectors, fields.OneTermNotEqualSelector(expr.Key, expr.Values[0]))

		default:
			return nil, fmt.Errorf("%q is not a valid node field selector operator", expr.Operator)
		}
	}

	return fields.AndSelectors(selectors...), nil
}
// NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
// fields.Selector.
NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
fields.Selector.
// NodeSelectorRequirementsAsFieldSelector converts the [] NodeSelectorRequirement core type into a struct that implements // fields . Selector .
func NodeSelectorRequirementsAsFieldSelector(nsm []v1.NodeSelectorRequirement) (fields.Selector, error) {
	if len(nsm) == 0 {
		return fields.Nothing(), nil
	}
	selectors := []fields.Selector{}
	for _, expr := range nsm {
		switch expr.Operator {
		case v1.NodeSelectorOpIn:
			if len(expr.Values) != 1 {
				return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
					len(expr.Values), expr.Operator)
			}
			selectors = append(selectors, fields.OneTermEqualSelector(expr.Key, expr.Values[0]))
		case v1.NodeSelectorOpNotIn:
			if len(expr.Values) != 1 {
				return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
					len(expr.Values), expr.Operator)
			}
			selectors = append(selectors, fields.OneTermNotEqualSelector(expr.Key, expr.Values[0]))
		default:
			return nil, fmt.Errorf("%q is not a valid node field selector operator", expr.Operator)
		}
	}
	return fields.AndSelectors(selectors...), nil
}
func NodeSelectorRequirementsAsFieldSelector ( nsm [ ] v1 . NodeSelectorRequirement ) ( fields . Selector , error ) { if len ( nsm ) == 0 { return fields . Nothing ( ) , nil } selectors := [ ] fields . Selector { } for _ , expr := range nsm { switch expr . Operator { case v1 . NodeSelectorOpIn : if len ( expr . Values ) != 1 { return nil , fmt . Errorf ( " " , len ( expr . Values ) , expr . Operator ) } selectors = append ( selectors , fields . OneTermEqualSelector ( expr . Key , expr . Values [ 0 ] ) ) case v1 . NodeSelectorOpNotIn : if len ( expr . Values ) != 1 { return nil , fmt . Errorf ( " " , len ( expr . Values ) , expr . Operator ) } selectors = append ( selectors , fields . OneTermNotEqualSelector ( expr . Key , expr . Values [ 0 ] ) ) default : return nil , fmt . Errorf ( " " , expr . Operator ) } } return fields . AndSelectors ( selectors ... ) , nil }
NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
fields.Selector.
NodeSelectorRequirementsAsFieldSelector converts the [] NodeSelectorRequirement core type into a struct that implements fields . Selector .