From 59079d881cf49c7f33033c7ac09deded5dd13a53 Mon Sep 17 00:00:00 2001 From: Shane Date: Tue, 19 Nov 2024 11:53:11 +0800 Subject: [PATCH] change some logic and variable name Signed-off-by: Shane --- apis/keda/v1alpha1/scaledobject_types.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apis/keda/v1alpha1/scaledobject_types.go b/apis/keda/v1alpha1/scaledobject_types.go index 1d6fed9d428..e40da6c51b2 100644 --- a/apis/keda/v1alpha1/scaledobject_types.go +++ b/apis/keda/v1alpha1/scaledobject_types.go @@ -277,20 +277,17 @@ func (so *ScaledObject) CheckReplicasNotNegative(replicas ...int32) bool { // GetIdleReplicasIfDefined returns bool based on whether idleRelicas is defined func (so *ScaledObject) GetIdleReplicasIfDefined() bool { - if so.Spec.IdleReplicaCount == nil { - return false - } else { - return true - } + return so.Spec.IdleReplicaCount != nil } // checkReplicaCountBoundsAreValid checks that Idle/Min/Max ReplicaCount defined in ScaledObject are correctly specified // i.e. that Min is not greater than Max or Idle greater or equal to Min func CheckReplicaCountBoundsAreValid(scaledObject *ScaledObject) error { + var idleReplicas *int32 minReplicas := *scaledObject.GetHPAMinReplicas() maxReplicas := scaledObject.GetHPAMaxReplicas() idleReplicasDefined := scaledObject.GetIdleReplicasIfDefined() - var idleReplicas *int32 = scaledObject.Spec.IdleReplicaCount + idleReplicas = scaledObject.Spec.IdleReplicaCount if !scaledObject.CheckReplicasNotNegative(minReplicas, maxReplicas) { return fmt.Errorf("MinReplicaCount=%d, MaxReplicaCount=%d must not be negative", minReplicas, maxReplicas)