func (sc *gatewaySource) filterByAnnotations(configs []istiomodel.Config) ([]istiomodel.Config, 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 configs, nil
	}

	filteredList := []istiomodel.Config{}

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

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

	return filteredList, nil
}
func (sc *gatewaySource) filterByAnnotations(configs []istiomodel.Config) ([]istiomodel.Config, 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 configs, nil
	}

	filteredList := []istiomodel.Config{}

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

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

	return filteredList, nil
}
func ( sc * gatewaySource ) filterByAnnotations ( configs [ ] istiomodel . Config ) ( [ ] istiomodel . Config , 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 configs , nil } filteredList := [ ] istiomodel . Config { } for _ , config := range configs { // convert the annotations to an equivalent label selector annotations := labels . Set ( config . Annotations ) // include if the annotations match the selector if selector . Matches ( annotations ) { filteredList = append ( filteredList , config ) } } return filteredList , nil }
// filterByAnnotations filters a list of configs by a given annotation selector.
filterByAnnotations filters a list of configs by a given annotation selector .