code: func LabelSelectorAsSelector(ps *LabelSelector) (labels.Selector, error) {
  	if ps == nil {
  		return labels.Nothing(), nil
  	}
  	if len(ps.MatchLabels)+len(ps.MatchExpressions) == 0 {
  		return labels.Everything(), nil
  	}
  	selector := labels.NewSelector()
  	for k, v := range ps.MatchLabels {
  		r, err := labels.NewRequirement(k, selection.Equals, []string{v})
  		if err != nil {
  			return nil, err
  		}
  		selector = selector.Add(*r)
  	}
  	for _, expr := range ps.MatchExpressions {
  		var op selection.Operator
  		switch expr.Operator {
  		case LabelSelectorOpIn:
  			op = selection.In
  		case LabelSelectorOpNotIn:
  			op = selection.NotIn
  		case LabelSelectorOpExists:
  			op = selection.Exists
  		case LabelSelectorOpDoesNotExist:
  			op = selection.DoesNotExist
  		default:
  			return nil, fmt.Errorf("%q is not a valid pod selector operator", expr.Operator)
  		}
  		r, err := labels.NewRequirement(expr.Key, op, append([]string(nil), expr.Values...))
  		if err != nil {
  			return nil, err
  		}
  		selector = selector.Add(*r)
  	}
  	return selector, nil
  }
docs: // LabelSelectorAsSelector converts the LabelSelector api type into a struct that implements
  // labels.Selector
  // Note: This function should be kept in sync with the selector methods in pkg/labels/selector.go