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