Skip to content

Commit

Permalink
change max,min
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Janiszewski <[email protected]>
  • Loading branch information
janisz committed May 14, 2024
1 parent 6db04a2 commit fa12c68
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/templates/updateconfig/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func parseIntOrString(data string) (*intstr.IntOrString, error) {

}

func compareIntOrString(max, min, actual *intstr.IntOrString) bool {
if max == nil && min == nil {
func compareIntOrString(maximal, minimal, actual *intstr.IntOrString) bool {
if maximal == nil && minimal == nil {
return true
}
if actual == nil {
Expand All @@ -61,25 +61,25 @@ func compareIntOrString(max, min, actual *intstr.IntOrString) bool {
return false
}
actualIsPercent := strings.Contains(actual.String(), "%")
if max != nil {
maxIsPercent := strings.Contains(max.String(), "%")
if maximal != nil {
maxIsPercent := strings.Contains(maximal.String(), "%")
if actualIsPercent != maxIsPercent {
return false
}
maxVal, err := intstr.GetValueFromIntOrPercent(max, 100, false)
maxVal, err := intstr.GetValueFromIntOrPercent(maximal, 100, false)
if err != nil {
return false
}
if actualVal > maxVal {
return false
}
}
if min != nil {
minIsPercent := strings.Contains(min.String(), "%")
if minimal != nil {
minIsPercent := strings.Contains(minimal.String(), "%")
if actualIsPercent != minIsPercent {
return false
}
minVal, err := intstr.GetValueFromIntOrPercent(min, 100, false)
minVal, err := intstr.GetValueFromIntOrPercent(minimal, 100, false)
if err != nil {
return false
}
Expand Down

0 comments on commit fa12c68

Please sign in to comment.