func checkDeprecatedHPAFields()

in operator/pkg/translate/translate.go [309:353]


func checkDeprecatedHPAFields(iop *v1alpha1.IstioOperatorSpec) bool {
	hpaSpecs := []*v1alpha1.HorizontalPodAutoscalerSpec{}
	if iop.GetComponents().GetPilot().GetK8S().GetHpaSpec() != nil {
		hpaSpecs = append(hpaSpecs, iop.GetComponents().GetPilot().GetK8S().GetHpaSpec())
	}
	for _, gwSpec := range iop.GetComponents().GetIngressGateways() {
		if gwSpec.Name == defaultIngressGWName && gwSpec.GetK8S().GetHpaSpec() != nil {
			hpaSpecs = append(hpaSpecs, gwSpec.GetK8S().GetHpaSpec())
		}
	}
	for _, gwSpec := range iop.GetComponents().GetEgressGateways() {
		if gwSpec.Name == defaultEgressGWName && gwSpec.GetK8S().GetHpaSpec() != nil {
			hpaSpecs = append(hpaSpecs, gwSpec.GetK8S().GetHpaSpec())
		}
	}
	for _, hpaSpec := range hpaSpecs {
		if hpaSpec.GetMetrics() != nil {
			for _, me := range hpaSpec.GetMetrics() {
				// nolint: staticcheck
				if me.GetObject().GetMetricName() != "" || me.GetObject().GetAverageValue() != nil ||
					// nolint: staticcheck
					me.GetObject().GetSelector() != nil || me.GetObject().GetTargetValue() != nil {
					return true
				}
				// nolint: staticcheck
				if me.GetPods().GetMetricName() != "" || me.GetPods().GetSelector() != nil ||
					// nolint: staticcheck
					me.GetPods().GetTargetAverageValue() != nil {
					return true
				}
				// nolint: staticcheck
				if me.GetResource().GetTargetAverageValue() != nil || me.GetResource().GetTargetAverageUtilization() != 0 {
					return true
				}
				// nolint: staticcheck
				if me.GetExternal().GetTargetAverageValue() != nil || me.GetExternal().GetTargetValue() != nil ||
					// nolint: staticcheck
					me.GetExternal().GetMetricName() != "" || me.GetExternal().GetMetricSelector() != nil {
					return true
				}
			}
		}
	}
	return false
}