Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0f04041

Browse files
committed
Adjust CPU recommendations from the API to render in cores
1 parent 49eb361 commit 0f04041

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/command/output.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ type RecommendationRow struct {
227227
}
228228

229229
func NewRecommendationRow(item *applications.RecommendationItem) *RecommendationRow {
230+
for i := range item.Parameters {
231+
for j := range item.Parameters[i].ContainerResources {
232+
fixCPU(item.Parameters[i].ContainerResources[j])
233+
}
234+
}
235+
230236
return &RecommendationRow{
231237
Name: item.Name,
232238
DeployedAtMachine: formatTime(item.DeployedAt, time.RFC3339),
@@ -616,3 +622,21 @@ func (s *sorter) Swap(i, j int) {
616622
s.keys[i], s.keys[j] = s.keys[j], s.keys[i]
617623
s.Output.Swap(i, j)
618624
}
625+
626+
// fixCPU is a hack to adjust the CPU value for display.
627+
func fixCPU(value interface{}) {
628+
switch value := value.(type) {
629+
case []interface{}:
630+
for i := range value {
631+
fixCPU(value[i])
632+
}
633+
case map[string]interface{}:
634+
for k, v := range value {
635+
if f, ok := v.(float64); ok && k == "cpu" {
636+
value[k] = f / 1000
637+
} else {
638+
fixCPU(v)
639+
}
640+
}
641+
}
642+
}

0 commit comments

Comments
 (0)