code: func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.Selector, error) {
  	if len(nsm) == 0 {
  		return labels.Nothing(), nil
  	}
  	selector := labels.NewSelector()
  	for _, expr := range nsm {
  		var op labels.Operator
  		switch expr.Operator {
  		case NodeSelectorOpIn:
  			op = labels.InOperator
  		case NodeSelectorOpNotIn:
  			op = labels.NotInOperator
  		case NodeSelectorOpExists:
  			op = labels.ExistsOperator
  		case NodeSelectorOpDoesNotExist:
  			op = labels.DoesNotExistOperator
  		case NodeSelectorOpGt:
  			op = labels.GreaterThanOperator
  		case NodeSelectorOpLt:
  			op = labels.LessThanOperator
  		default:
  			return nil, fmt.Errorf("%q is not a valid node selector operator", expr.Operator)
  		}
  		r, err := labels.NewRequirement(expr.Key, op, sets.NewString(expr.Values...))
  		if err != nil {
  			return nil, err
  		}
  		selector = selector.Add(*r)
  	}
  	return selector, nil
  }
docs: // NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement api type into a struct that implements
  // labels.Selector.