code: func ParseToLabelSelector(selector string) (*LabelSelector, error) {
  	reqs, err := labels.ParseToRequirements(selector)
  	if err != nil {
  		return nil, fmt.Errorf("couldn't parse the selector string \"%s\": %v", selector, err)
  	}
  
  	labelSelector := &LabelSelector{
  		MatchLabels:      map[string]string{},
  		MatchExpressions: []LabelSelectorRequirement{},
  	}
  	for _, req := range reqs {
  		var op LabelSelectorOperator
  		switch req.Operator() {
  		case selection.Equals, selection.DoubleEquals:
  			vals := req.Values()
  			if vals.Len() != 1 {
  				return nil, fmt.Errorf("equals operator must have exactly one value")
  			}
  			val, ok := vals.PopAny()
  			if !ok {
  				return nil, fmt.Errorf("equals operator has exactly one value but it cannot be retrieved")
  			}
  			labelSelector.MatchLabels[req.Key()] = val
  			continue
  		case selection.In:
  			op = LabelSelectorOpIn
  		case selection.NotIn:
  			op = LabelSelectorOpNotIn
  		case selection.Exists:
  			op = LabelSelectorOpExists
  		case selection.DoesNotExist:
  			op = LabelSelectorOpDoesNotExist
  		case selection.GreaterThan, selection.LessThan:
  			// Adding a separate case for these operators to indicate that this is deliberate
  			return nil, fmt.Errorf("%q isn't supported in label selectors", req.Operator())
  		default:
  			return nil, fmt.Errorf("%q is not a valid label selector operator", req.Operator())
  		}
  		labelSelector.MatchExpressions = append(labelSelector.MatchExpressions, LabelSelectorRequirement{
  			Key:      req.Key(),
  			Operator: op,
  			Values:   req.Values().List(),
  		})
  	}
  	return labelSelector, nil
  }
docs: // ParseToLabelSelector parses a string representing a selector into a LabelSelector object.
  // Note: This function should be kept in sync with the parser in pkg/labels/selector.go