in cost-optimization/gke-shift-left-cost/api/cost.go [288:338]
func (d *DiffCostRange) status() (summary string, costIncrease bool) {
var costInc, costDec []string
if d.DiffPercentage.MinRequested > 0 {
costInc = append(costInc, headers[0])
}
if d.DiffPercentage.HPABuffer > 0 {
costInc = append(costInc, headers[1])
}
if d.DiffPercentage.MaxRequested > 0 {
costInc = append(costInc, headers[2])
}
if d.DiffPercentage.MinLimited > 0 {
costInc = append(costInc, headers[3])
}
if d.DiffPercentage.MaxLimited > 0 {
costInc = append(costInc, headers[4])
}
if d.DiffPercentage.MinRequested < 0 {
costDec = append(costDec, headers[0])
}
if d.DiffPercentage.HPABuffer < 0 {
costDec = append(costDec, headers[1])
}
if d.DiffPercentage.MaxRequested < 0 {
costDec = append(costDec, headers[2])
}
if d.DiffPercentage.MinLimited < 0 {
costDec = append(costDec, headers[3])
}
if d.DiffPercentage.MaxLimited < 0 {
costDec = append(costDec, headers[4])
}
if len(costInc) > 0 {
costIncrease = true
summary = summary + fmt.Sprintf("There are increase in costs on: '%s'", strings.Join(costInc, "', '"))
}
if len(costDec) > 0 {
start := "There"
if len(summary) > 0 {
start = ". And there"
}
summary = summary + fmt.Sprintf("%s are decrease in costs on: '%s'", start, strings.Join(costDec, "', '"))
}
if len(costInc) == 0 && len(costDec) == 0 {
summary = "No cost change found!"
}
return
}