Add CCR stuff, fix search, add docs support, support index maps, refactor (#13)

This commit is contained in:
T. von Dein
2026-05-12 18:28:57 +02:00
parent 327bc84bd8
commit dd619ab815
19 changed files with 717 additions and 237 deletions

View File

@@ -18,7 +18,6 @@ package es
import (
"context"
"errors"
"fmt"
"log/slog"
"slices"
@@ -47,46 +46,6 @@ type apiResponse struct {
which int
}
func ClusterCompare(conf *cfg.Config, leader, follower string) error {
if !checkClusterFollower(conf, leader) {
return errors.New("leader/follower attribution is invalid, reverse cluster attribution and retry")
}
indices := ClusterIndices{}
for _, alias := range []string{leader, follower} {
cat := conf.Clusters[alias].ES.Cat.Indices().
// we need to add custom request headers, required for older ES instances
Header("content-type", "application/json").
Header("accept", "application/json")
res, err := cat.Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get indicies on %s: %s", alias, err)
}
indices[alias] = make(map[string]*types.IndicesRecord, len(res))
for _, index := range res {
indices[alias][*index.Index] = &index
}
}
if !checkClusterStatus(conf, leader, follower) {
return errors.New("one of the two clusters is in a failed state")
}
findIlmErrors(conf, leader, follower)
if findIndicesOnlyOnLeader(conf, indices, leader, follower) &&
findOrphanedIndices(conf, indices, leader, follower) &&
findFailedFollowerIndices(conf, indices, follower) {
fmt.Println("everything's hunky-dory.")
}
return nil
}
func ClusterList(conf *cfg.Config) error {
table := NewTable(3, len(conf.Clusters))
@@ -102,8 +61,6 @@ func ClusterList(conf *cfg.Config) error {
slices.Sort(names)
idx = 0
for idx, name := range names {
current := name == "default" || name == conf.CurrentCluster
cluster := conf.Clusters[name]
@@ -118,7 +75,6 @@ func ClusterList(conf *cfg.Config) error {
}
table.entries[idx] = []string{name, cluster.Uri, fmt.Sprintf("%t", current)}
idx++
}
if err := table.PrintMarkdown(); err != nil {