in pkg/model/uimodel.go [150:181]
func (u *UIModel) writeClusterSummary(resources []v1.ResourceName, stats Stats, w io.Writer) {
firstLine := true
for _, res := range resources {
allocatable := stats.AllocatableResources[res]
used := stats.UsedResources[res]
pctUsed := 0.0
if allocatable.AsApproximateFloat64() != 0 {
pctUsed = 100 * (used.AsApproximateFloat64() / allocatable.AsApproximateFloat64())
}
pctUsedStr := fmt.Sprintf("%0.1f%%", pctUsed)
if pctUsed > 90 {
pctUsedStr = green(pctUsedStr)
} else if pctUsed > 60 {
pctUsedStr = yellow(pctUsedStr)
} else {
pctUsedStr = red(pctUsedStr)
}
u.progress.ShowPercentage = false
monthlyPrice := stats.TotalPrice * (365 * 24) / 12 // average hours per month
clusterPrice := fmt.Sprintf("%0.3f/hour $%0.3f/month", stats.TotalPrice, monthlyPrice)
if firstLine {
fmt.Fprintf(w, "%d nodes\t%s/%s\t%s\t%s\t%s\t%s\n",
stats.NumNodes, used.String(), allocatable.String(), pctUsedStr, res, u.progress.ViewAs(pctUsed/100.0), clusterPrice)
} else {
fmt.Fprintf(w, " \t%s/%s\t%s\t%s\t%s\t\n",
used.String(), allocatable.String(), pctUsedStr, res, u.progress.ViewAs(pctUsed/100.0))
}
firstLine = false
}
}