internal/rework-table (#74)

This commit is contained in:
T. von Dein
2026-07-07 07:29:03 +02:00
parent 92865c0fe2
commit c35ffa5e4b
26 changed files with 300 additions and 362 deletions

View File

@@ -72,27 +72,27 @@ func checkClusterStatus(conf *cfg.Config, leader, follower string) bool {
table.Addheaders("setting", "leader:"+leader, "follower:"+follower)
table.Entries = [][]string{
table.Entries = [][]any{
{"Cluster Name", status[leader].ClusterName, status[follower].ClusterName},
{"Cluster Status",
printer.Colorize(conf, status[leader].Status.Name, status[leader].Status.Name),
printer.Colorize(conf, status[follower].Status.Name, status[follower].Status.Name),
},
{"Active Shards",
fmt.Sprintf("%d", status[leader].ActiveShards),
fmt.Sprintf("%d", status[follower].ActiveShards),
status[leader].ActiveShards,
status[follower].ActiveShards,
},
{"Active Primary Shards",
fmt.Sprintf("%d", status[leader].ActivePrimaryShards),
fmt.Sprintf("%d", status[follower].ActivePrimaryShards),
status[leader].ActivePrimaryShards,
status[follower].ActivePrimaryShards,
},
{"Indicies",
fmt.Sprintf("%d", len(status[leader].Indices)),
fmt.Sprintf("%d", len(status[follower].Indices)),
len(status[leader].Indices),
len(status[follower].Indices),
},
{"Nodes",
fmt.Sprintf("%d", status[leader].NumberOfNodes),
fmt.Sprintf("%d", status[follower].NumberOfNodes),
status[leader].NumberOfNodes,
status[follower].NumberOfNodes,
},
}
@@ -112,7 +112,7 @@ func checkClusterStatus(conf *cfg.Config, leader, follower string) bool {
// finds indices on both clusters which have ilm errors
func findIlmErrors(conf *cfg.Config, leader, follower string) bool {
failed := map[string]map[string]string{}
failed := map[string]map[string]any{}
for _, cluster := range []string{leader, follower} {
ilm, err := conf.Clusters[cluster].ES().Ilm.ExplainLifecycle("_all").
@@ -123,13 +123,13 @@ func findIlmErrors(conf *cfg.Config, leader, follower string) bool {
return false
}
failed[cluster] = map[string]string{}
failed[cluster] = map[string]any{}
for name, ilmstate := range ilm.Indices {
count := ilmstate.(*types.LifecycleExplainManaged).FailedStepRetryCount
if count != nil && *count > 0 {
failed[cluster][name] = fmt.Sprintf("%d", *count)
failed[cluster][name] = *count
}
}
}
@@ -150,7 +150,7 @@ func findIlmErrors(conf *cfg.Config, leader, follower string) bool {
table.Addheaders("ilm errors on "+which, "errors")
for name, count := range failed[cluster] {
table.Entries[idx] = []string{name, count}
table.Entries[idx] = []any{name, count}
idx++
}
@@ -222,7 +222,7 @@ func findIndicesOnlyOnLeader(conf *cfg.Config, indices ClusterIndices, leader, f
for name, index := range indexOnlyOnLeader {
name := printer.Colorize(conf, "red", name)
table.Entries[idx] = []string{name, *index.DatasetSize, *index.DocsCount}
table.Entries[idx] = []any{name, *index.DatasetSize, *index.DocsCount}
idx++
}
@@ -270,7 +270,7 @@ func findOrphanedIndices(conf *cfg.Config, indices ClusterIndices, leader, follo
for name, index := range orphaned {
name := printer.Colorize(conf, "red", name)
table.Entries[idx] = []string{name, *index.DatasetSize, *index.DocsCount}
table.Entries[idx] = []any{name, *index.DatasetSize, *index.DocsCount}
idx++
}
@@ -304,7 +304,7 @@ func findFailedFollowerIndices(conf *cfg.Config, indices ClusterIndices, followe
for name, index := range red {
name := printer.Colorize(conf, "red", name)
table.Entries[idx] = []string{name, *index.DatasetSize, *index.DocsCount}
table.Entries[idx] = []any{name, *index.DatasetSize, *index.DocsCount}
idx++
}