fix cluster list sorting

This commit is contained in:
2026-05-11 14:03:30 +02:00
parent a785eb642f
commit 327bc84bd8

View File

@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"log/slog"
"slices"
"sync"
"codeberg.org/scip/esctl/pkg/cfg"
@@ -92,8 +93,20 @@ func ClusterList(conf *cfg.Config) error {
table.Addheaders("cluster", "uri", "default")
idx := 0
for name, cluster := range conf.Clusters {
names := make([]string, len(conf.Clusters))
for name := range conf.Clusters {
names[idx] = name
idx++
}
slices.Sort(names)
idx = 0
for idx, name := range names {
current := name == "default" || name == conf.CurrentCluster
cluster := conf.Clusters[name]
_, err := cluster.ES.Cluster.Health().
Header("content-type", "application/json").
@@ -108,7 +121,6 @@ func ClusterList(conf *cfg.Config) error {
idx++
}
table.Sort()
if err := table.PrintMarkdown(); err != nil {
return err
}