mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 06:24:18 +02:00
fix cluster list sorting
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user