func DiffExternalMetrics(informerList []*autoscalingv2.HorizontalPodAutoscaler, wpaInformerList []*v1alpha1.WatermarkPodAutoscaler, storedMetricsList []custommetrics.ExternalMetricValue) (toDelete []custommetrics.ExternalMetricValue) {
	autoscalerMetrics := map[string][]custommetrics.ExternalMetricValue{}

	for _, hpa := range informerList {
		autoscalerMetrics[string(hpa.UID)] = InspectHPA(hpa)
	}

	for _, wpa := range wpaInformerList {
		autoscalerMetrics[string(wpa.UID)] = InspectWPA(wpa)
	}

	for _, em := range storedMetricsList {
		var found bool
		emList := autoscalerMetrics[em.Ref.UID]

		if emList == nil {
			toDelete = append(toDelete, em)
			continue
		}
		for _, m := range emList {
			// We have previously processed an external metric from this Ref.
			// Check that it's still the same. If not, remove the entry from the Global Store.
			// Use the Ref Type to get rid of the old template in the Store
			if em.MetricName == m.MetricName && reflect.DeepEqual(em.Labels, m.Labels) && em.Ref.Type == m.Ref.Type {
				found = true
				break
			}
		}
		if !found {
			toDelete = append(toDelete, em)
		}
	}
	return
}
// DiffExternalMetrics returns the list of external metrics that reference hpas that are not in the given list of hpas.
DiffExternalMetrics returns the list of external metrics that reference hpas that are not in the given list of hpas.
// DiffExternalMetrics returns the list of external metrics that reference hpas that are not in the given list of hpas .
func DiffExternalMetrics(informerList []*autoscalingv2.HorizontalPodAutoscaler, wpaInformerList []*v1alpha1.WatermarkPodAutoscaler, storedMetricsList []custommetrics.ExternalMetricValue) (toDelete []custommetrics.ExternalMetricValue) {
	autoscalerMetrics := map[string][]custommetrics.ExternalMetricValue{}
	for _, hpa := range informerList {
		autoscalerMetrics[string(hpa.UID)] = InspectHPA(hpa)
	}
	for _, wpa := range wpaInformerList {
		autoscalerMetrics[string(wpa.UID)] = InspectWPA(wpa)
	}
	for _, em := range storedMetricsList {
		var found bool
		emList := autoscalerMetrics[em.Ref.UID]
		if emList == nil {
			toDelete = append(toDelete, em)
			continue
		}
		for _, m := range emList {
			if em.MetricName == m.MetricName && reflect.DeepEqual(em.Labels, m.Labels) && em.Ref.Type == m.Ref.Type {
				found = true
				break
			}
		}
		if !found {
			toDelete = append(toDelete, em)
		}
	}
	return
}
func DiffExternalMetrics ( informerList [ ] * autoscalingv2 . HorizontalPodAutoscaler , wpaInformerList [ ] * v1alpha1 . WatermarkPodAutoscaler , storedMetricsList [ ] custommetrics . ExternalMetricValue ) ( toDelete [ ] custommetrics . ExternalMetricValue ) { autoscalerMetrics := map [ string ] [ ] custommetrics . ExternalMetricValue { } for _ , hpa := range informerList { autoscalerMetrics [ string ( hpa . UID ) ] = InspectHPA ( hpa ) } for _ , wpa := range wpaInformerList { autoscalerMetrics [ string ( wpa . UID ) ] = InspectWPA ( wpa ) } for _ , em := range storedMetricsList { var found bool emList := autoscalerMetrics [ em . Ref . UID ] if emList == nil { toDelete = append ( toDelete , em ) continue } for _ , m := range emList { if em . MetricName == m . MetricName && reflect . DeepEqual ( em . Labels , m . Labels ) && em . Ref . Type == m . Ref . Type { found = true break } } if ! found { toDelete = append ( toDelete , em ) } } return }
DiffExternalMetrics returns the list of external metrics that reference hpas that are not in the given list of hpas.
DiffExternalMetrics returns the list of external metrics that reference hpas that are not in the given list of hpas .
// We have previously processed an external metric from this Ref. // Check that it's still the same. If not, remove the entry from the Global Store. // Use the Ref Type to get rid of the old template in the Store