// ValidateHpaConfigs validate the HPA yaml config read from config map "hpa-configs"
// and setting values
ValidateHpaConfigs validate the HPA yaml config read from config map "hpa-configs"
and setting values
// ValidateHpaConfigs validate the HPA yaml config read from config map " hpa - configs " // and setting values
func ValidateHpaConfigs(client *client.Client) error {
	hpaConfMap := k8s.NewConfMap()
	err := k8s.Get(client, types.NamespacedName{Namespace: config.SystemNamespace, Name: hpaConfigMapName}, hpaConfMap)
	if err != nil {
		return err
	}
	maxReplicasInt64, errInt := strconv.ParseInt(hpaConfMap.Data[maxReplicasConfigKey], 10, 32)
	if errInt != nil {
		logHpa.Error(err, "Error parsing HPA MaxReplicas",
			"value", hpaConfMap.Data[maxReplicasConfigKey])
		return err
	}
	hpaMaxReplicas = int32(maxReplicasInt64)
	if strings.EqualFold("v2beta1", hpaConfMap.Data[hpaVersionConst]) {
		metricsHpaV2beta1 = []v2beta1.MetricSpec{}
		yamlErr := yaml.Unmarshal([]byte(hpaConfMap.Data[metricsConfigKeyV2beta1]), metricsHpaV2beta1)
		if yamlErr != nil {
			logHpa.Error(err, "Error marshalling HPA config yaml", "configmap", hpaConfMap)
			return yamlErr
		}
	} else if strings.EqualFold("v2beta2", hpaConfMap.Data[hpaVersionConst]) {
		metricsHpaV2beta2 = &[]v2beta2.MetricSpec{}
		yamlErr := yaml.Unmarshal([]byte(hpaConfMap.Data[metricsConfigKey]), metricsHpaV2beta2)
		if yamlErr != nil {
			logHpa.Error(err, "Error marshalling HPA config yaml", "configmap", hpaConfMap)
			return yamlErr
		}
	} else {
		err = errors.New("invalid HPA Version")
		logHpa.Error(err, "Error getting the HPA version. HPA version is invalid")
		return err
	}
	return nil
}
func ValidateHpaConfigs ( client * client . Client ) error { hpaConfMap := k8s . NewConfMap ( ) err := k8s . Get ( client , types . NamespacedName { Namespace : config . SystemNamespace , Name : hpaConfigMapName } , hpaConfMap ) if err != nil { return err } maxReplicasInt64 , errInt := strconv . ParseInt ( hpaConfMap . Data [ maxReplicasConfigKey ] , 10 , 32 ) if errInt != nil { logHpa . Error ( err , " " , " " , hpaConfMap . Data [ maxReplicasConfigKey ] ) return err } hpaMaxReplicas = int32 ( maxReplicasInt64 ) if strings . EqualFold ( " " , hpaConfMap . Data [ hpaVersionConst ] ) { metricsHpaV2beta1 = [ ] v2beta1 . MetricSpec { } yamlErr := yaml . Unmarshal ( [ ] byte ( hpaConfMap . Data [ metricsConfigKeyV2beta1 ] ) , metricsHpaV2beta1 ) if yamlErr != nil { logHpa . Error ( err , " " , " " , hpaConfMap ) return yamlErr } } else if strings . EqualFold ( " " , hpaConfMap . Data [ hpaVersionConst ] ) { metricsHpaV2beta2 = & [ ] v2beta2 . MetricSpec { } yamlErr := yaml . Unmarshal ( [ ] byte ( hpaConfMap . Data [ metricsConfigKey ] ) , metricsHpaV2beta2 ) if yamlErr != nil { logHpa . Error ( err , " " , " " , hpaConfMap ) return yamlErr } } else { err = errors . New ( " " ) logHpa . Error ( err , " " ) return err } return nil }
ValidateHpaConfigs validate the HPA yaml config read from config map "hpa-configs"
and setting values
ValidateHpaConfigs validate the HPA yaml config read from config map " hpa - configs " and setting values
// get global hpa configs, return error if not found (required config map) // set max replica count // parse hpa config yaml // parse hpa config yaml