@@ -1275,10 +1275,10 @@ func calculateScaleUpLimitWithScalingRules(currentReplicas int32, scaleUpEvents,
1275
1275
return currentReplicas // Scaling is disabled
1276
1276
} else if * scalingRules .SelectPolicy == autoscalingv2 .MinChangePolicySelect {
1277
1277
result = math .MaxInt32
1278
- selectPolicyFn = min // For scaling up, the lowest change ('min' policy) produces a minimum value
1278
+ selectPolicyFn = minInt32 // For scaling up, the lowest change ('min' policy) produces a minimum value
1279
1279
} else {
1280
1280
result = math .MinInt32
1281
- selectPolicyFn = max // Use the default policy otherwise to produce a highest possible change
1281
+ selectPolicyFn = maxInt32 // Use the default policy otherwise to produce a highest possible change
1282
1282
}
1283
1283
for _ , policy := range scalingRules .Policies {
1284
1284
replicasAddedInCurrentPeriod := getReplicasChangePerPeriod (policy .PeriodSeconds , scaleUpEvents )
@@ -1304,10 +1304,10 @@ func calculateScaleDownLimitWithBehaviors(currentReplicas int32, scaleUpEvents,
1304
1304
return currentReplicas // Scaling is disabled
1305
1305
} else if * scalingRules .SelectPolicy == autoscalingv2 .MinChangePolicySelect {
1306
1306
result = math .MinInt32
1307
- selectPolicyFn = max // For scaling down, the lowest change ('min' policy) produces a maximum value
1307
+ selectPolicyFn = maxInt32 // For scaling down, the lowest change ('min' policy) produces a maximum value
1308
1308
} else {
1309
1309
result = math .MaxInt32
1310
- selectPolicyFn = min // Use the default policy otherwise to produce a highest possible change
1310
+ selectPolicyFn = minInt32 // Use the default policy otherwise to produce a highest possible change
1311
1311
}
1312
1312
for _ , policy := range scalingRules .Policies {
1313
1313
replicasAddedInCurrentPeriod := getReplicasChangePerPeriod (policy .PeriodSeconds , scaleUpEvents )
@@ -1434,16 +1434,12 @@ func setConditionInList(inputList []autoscalingv2.HorizontalPodAutoscalerConditi
1434
1434
return resList
1435
1435
}
1436
1436
1437
- func max (a , b int32 ) int32 {
1438
- if a >= b {
1439
- return a
1440
- }
1441
- return b
1437
+ // minInt32 is a wrapper around the min builtin to be used as a function value.
1438
+ func minInt32 (a , b int32 ) int32 {
1439
+ return min (a , b )
1442
1440
}
1443
1441
1444
- func min (a , b int32 ) int32 {
1445
- if a <= b {
1446
- return a
1447
- }
1448
- return b
1442
+ // maxInt32 is a wrapper around the max builtin to be used as a function value.
1443
+ func maxInt32 (a , b int32 ) int32 {
1444
+ return max (a , b )
1449
1445
}
0 commit comments