Skip to content

Commit

Permalink
moved percent colour limits to setColourValue
Browse files Browse the repository at this point in the history
  • Loading branch information
NimbleArchitect committed Feb 3, 2023
1 parent aaa6f9a commit 9e86ec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions pkg/plugin/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,22 @@ func (s *resource) BuildBranch(info BuilderInformation, rows [][]Cell) ([]Cell,
val := validateFloat64(float64(rowOut[0].number) / float64(rowOut[1].number) * 100)
rowOut[4].text = fmt.Sprintf(floatfmt, val)
rowOut[4].float = val
rowOut[4].colour = setColourValue(int(val), 90, 75)
rowOut[4].colour = setColourValue(int(val))
}

if rowOut[2].number > 0.0 {
// calc % limit
val := validateFloat64(float64(rowOut[0].number) / float64(rowOut[2].number) * 100)
rowOut[3].text = fmt.Sprintf(floatfmt, val)
rowOut[3].float = val
rowOut[3].colour = setColourValue(int(val), 90, 75)
rowOut[3].colour = setColourValue(int(val))
}

usedColour := 0
if rowOut[3].float > rowOut[4].float {
usedColour = setColourValue(int(rowOut[4].float), 90, 75)
usedColour = setColourValue(int(rowOut[4].float))
} else {
usedColour = setColourValue(int(rowOut[3].float), 90, 75)
usedColour = setColourValue(int(rowOut[3].float))
}

rowOut[0].colour = usedColour
Expand Down Expand Up @@ -301,7 +301,7 @@ func (s *resource) statsProcessTableRow(res v1.ResourceRequirements, metrics v1.
percentLimit = fmt.Sprintf(floatfmt, val)
rawPercentLimit = val

percentLimitColour = setColourValue(int(val), 90, 75)
percentLimitColour = setColourValue(int(val))
}
// check cpu requests has a value
if res.Requests.Cpu().AsApproximateFloat64() == 0 {
Expand All @@ -312,7 +312,7 @@ func (s *resource) statsProcessTableRow(res v1.ResourceRequirements, metrics v1.
percentRequest = fmt.Sprintf(floatfmt, val)
rawPercentRequest = val

percentRequestColour = setColourValue(int(val), 90, 75)
percentRequestColour = setColourValue(int(val))
}
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func (s *resource) statsProcessTableRow(res v1.ResourceRequirements, metrics v1.
percentLimit = fmt.Sprintf(floatfmt, val)
rawPercentLimit = val

percentLimitColour = setColourValue(int(val), 90, 75)
percentLimitColour = setColourValue(int(val))
}
// check memory requests has a value
if res.Requests.Memory().AsApproximateFloat64() == 0 {
Expand All @@ -365,7 +365,7 @@ func (s *resource) statsProcessTableRow(res v1.ResourceRequirements, metrics v1.
percentRequest = fmt.Sprintf(floatfmt, val)
rawPercentRequest = val

percentRequestColour = setColourValue(int(val), 90, 75)
percentRequestColour = setColourValue(int(val))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/plugin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ func portAsString(port intstr.IntOrString) string {
return ""
}

func setColourValue(value int, bad int, warn int) int {
func setColourValue(value int) int {
var colour int

colour = colourOk
if value > bad {
if value > 90 {
colour = colourBad
} else if value > warn {
} else if value > 75 {
colour = colourWarn
}

Expand Down

0 comments on commit 9e86ec5

Please sign in to comment.