mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 11:34:17 +02:00
fix cluster list sorting
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"codeberg.org/scip/esctl/pkg/cfg"
|
"codeberg.org/scip/esctl/pkg/cfg"
|
||||||
@@ -92,8 +93,20 @@ func ClusterList(conf *cfg.Config) error {
|
|||||||
table.Addheaders("cluster", "uri", "default")
|
table.Addheaders("cluster", "uri", "default")
|
||||||
|
|
||||||
idx := 0
|
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
|
current := name == "default" || name == conf.CurrentCluster
|
||||||
|
cluster := conf.Clusters[name]
|
||||||
|
|
||||||
_, err := cluster.ES.Cluster.Health().
|
_, err := cluster.ES.Cluster.Health().
|
||||||
Header("content-type", "application/json").
|
Header("content-type", "application/json").
|
||||||
@@ -108,7 +121,6 @@ func ClusterList(conf *cfg.Config) error {
|
|||||||
idx++
|
idx++
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Sort()
|
|
||||||
if err := table.PrintMarkdown(); err != nil {
|
if err := table.PrintMarkdown(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user