diff --git a/pkg/es/cluster_util.go b/pkg/es/cluster_util.go index f14fbde..b4ac306 100644 --- a/pkg/es/cluster_util.go +++ b/pkg/es/cluster_util.go @@ -25,7 +25,7 @@ import ( "sync" "codeberg.org/scip/esctl/pkg/cfg" - "codeberg.org/scip/esctl/pkg/printer" + "codeberg.org/scip/esctl/pkg/printer" "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/go-elasticsearch/v9/typedapi/cluster/health" "github.com/elastic/go-elasticsearch/v9/typedapi/types" @@ -75,14 +75,15 @@ func checkClusterStatus(conf *cfg.Config, leader, follower string) bool { status[cluster] = st } - table := printer.NewTable(conf, 3, 5) + table := printer.NewTable(conf, 3, 6) table.Addheaders("setting", "leader:"+leader, "follower:"+follower) table.Entries = [][]string{ - {"Cluster Name", - printer.Colorize(conf, status[leader].Status.Name, status[leader].ClusterName), - printer.Colorize(conf, status[follower].Status.Name, status[follower].ClusterName), + {"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), @@ -107,6 +108,8 @@ func checkClusterStatus(conf *cfg.Config, leader, follower string) bool { return false } + fmt.Println() + if status[leader].Status.Name == "green" && status[follower].Status.Name == "green" { return true } diff --git a/pkg/printer/color.go b/pkg/printer/color.go index 2c328c6..dab9f79 100644 --- a/pkg/printer/color.go +++ b/pkg/printer/color.go @@ -24,6 +24,7 @@ import ( var ( green = color.New(color.BgGreen, color.FgHiWhite).SprintFunc() + yellow = color.New(color.BgYellow, color.FgHiWhite).SprintFunc() orange = color.BgRGB(255, 128, 0).AddRGB(0, 0, 0).SprintFunc() red = color.New(color.BgRed, color.FgHiWhite).SprintFunc() bold = color.New(color.Bold).SprintFunc() @@ -42,6 +43,8 @@ func Colorize(conf *cfg.Config, col, what string) string { what = orange(what) case "red": what = red(what) + case "yellow": + what = yellow(what) } return what