mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
eval status: sort plan annotations by task group (#26428)
The plan annotations table isn't sorted by task group, which makes for a less beautiful UX and a flaky test.
This commit is contained in:
@@ -5,6 +5,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -382,8 +383,16 @@ func formatPlanAnnotations(desiredTGUpdates map[string]*api.DesiredUpdates, verb
|
||||
}
|
||||
}
|
||||
|
||||
taskGroups := []string{}
|
||||
for tg := range desiredTGUpdates {
|
||||
taskGroups = append(taskGroups, tg)
|
||||
}
|
||||
slices.Sort(taskGroups)
|
||||
|
||||
i := 1
|
||||
for tg, updates := range desiredTGUpdates {
|
||||
for _, tg := range taskGroups {
|
||||
updates := desiredTGUpdates[tg]
|
||||
|
||||
// we always show the first 5 columns
|
||||
annotations[i] = fmt.Sprintf("%s|%d|%d|%d|%d|%d",
|
||||
tg,
|
||||
|
||||
@@ -236,6 +236,6 @@ func TestEvalStatus_FormatPlanAnnotations(t *testing.T) {
|
||||
|
||||
out := formatPlanAnnotations(updates, false)
|
||||
must.Eq(t, `Task Group Ignore Place Stop InPlace Destructive Canary Reconnect
|
||||
foo 2 1 0 0 0 1 0
|
||||
bar 0 1 3 0 0 0 2`, out)
|
||||
bar 0 1 3 0 0 0 2
|
||||
foo 2 1 0 0 0 1 0`, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user