source/ingress.go
func (sc *ingressSource) filterByAnnotations(ingresses []*v1beta1.Ingress) ([]*v1beta1.Ingress, error) {
	labelSelector, err := metav1.ParseToLabelSelector(sc.annotationFilter)
	if err != nil {
		return nil, err
	}
	selector, err := metav1.LabelSelectorAsSelector(labelSelector)
	if err != nil {
		return nil, err
	}

	// empty filter returns original list
	if selector.Empty() {
		return ingresses, nil
	}

	filteredList := []*v1beta1.Ingress{}

	for _, ingress := range ingresses {
		// convert the ingress' annotations to an equivalent label selector
		annotations := labels.Set(ingress.Annotations)

		// include ingress if its annotations match the selector
		if selector.Matches(annotations) {
			filteredList = append(filteredList, ingress)
		}
	}

	return filteredList, nil
}
func (sc *ingressSource) filterByAnnotations(ingresses []*v1beta1.Ingress) ([]*v1beta1.Ingress, error) {
	labelSelector, err := metav1.ParseToLabelSelector(sc.annotationFilter)
	if err != nil {
		return nil, err
	}
	selector, err := metav1.LabelSelectorAsSelector(labelSelector)
	if err != nil {
		return nil, err
	}

	// empty filter returns original list
	if selector.Empty() {
		return ingresses, nil
	}

	filteredList := []*v1beta1.Ingress{}

	for _, ingress := range ingresses {
		// convert the ingress' annotations to an equivalent label selector
		annotations := labels.Set(ingress.Annotations)

		// include ingress if its annotations match the selector
		if selector.Matches(annotations) {
			filteredList = append(filteredList, ingress)
		}
	}

	return filteredList, nil
}
func ( sc * ingressSource ) filterByAnnotations ( ingresses [ ] * v1beta1 . Ingress ) ( [ ] * v1beta1 . Ingress , error ) { labelSelector , err := metav1 . ParseToLabelSelector ( sc . annotationFilter ) if err != nil { return nil , err } selector , err := metav1 . LabelSelectorAsSelector ( labelSelector ) if err != nil { return nil , err } // empty filter returns original list if selector . Empty ( ) { return ingresses , nil } filteredList := [ ] * v1beta1 . Ingress { } for _ , ingress := range ingresses { // convert the ingress' annotations to an equivalent label selector annotations := labels . Set ( ingress . Annotations ) // include ingress if its annotations match the selector if selector . Matches ( annotations ) { filteredList = append ( filteredList , ingress ) } } return filteredList , nil }
// filterByAnnotations filters a list of ingresses by a given annotation selector.
filterByAnnotations filters a list of ingresses by a given annotation selector .