From 0ae5b3f39b4677ae5021290b06cbbf8266fb4264 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Tue, 5 Aug 2025 09:36:12 -0400 Subject: [PATCH] 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. --- command/eval_status.go | 11 ++++++++++- command/eval_status_test.go | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/command/eval_status.go b/command/eval_status.go index bffe62cb0..4b3f738c7 100644 --- a/command/eval_status.go +++ b/command/eval_status.go @@ -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, diff --git a/command/eval_status_test.go b/command/eval_status_test.go index 096007f95..582ed6399 100644 --- a/command/eval_status_test.go +++ b/command/eval_status_test.go @@ -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) }