Skip to content

Commit

Permalink
change some logic and variable name
Browse files Browse the repository at this point in the history
Signed-off-by: Shane <[email protected]>
  • Loading branch information
ctccxxd committed Nov 19, 2024
1 parent e3cb479 commit 59079d8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions apis/keda/v1alpha1/scaledobject_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 59079d8

Please sign in to comment.