From 97fe232a9aabe88547894c9eda719d85a0502103 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 25 Sep 2024 02:56:38 -0700 Subject: [PATCH] add alias name to 'mc ready' (#5044) --- cmd/{ready.go => ready-main.go} | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) rename cmd/{ready.go => ready-main.go} (85%) diff --git a/cmd/ready.go b/cmd/ready-main.go similarity index 85% rename from cmd/ready.go rename to cmd/ready-main.go index 62c3da1b..d3eb89c8 100644 --- a/cmd/ready.go +++ b/cmd/ready-main.go @@ -19,6 +19,7 @@ package cmd import ( "context" + "fmt" "time" "github.com/fatih/color" @@ -73,10 +74,12 @@ EXAMPLES: } type readyMessage struct { - Healthy bool `json:"healthy"` - MaintenanceMode bool `json:"maintenanceMode"` - WriteQuorum int `json:"writeQuorum"` - HealingDrives int `json:"healingDrives"` + Status string `json:"status"` + Alias string `json:"alias"` + Healthy bool `json:"healthy"` + MaintenanceMode bool `json:"maintenanceMode"` + WriteQuorum int `json:"writeQuorum"` + HealingDrives int `json:"healingDrives"` Err error `json:"error"` } @@ -84,11 +87,11 @@ type readyMessage struct { func (r readyMessage) String() string { switch { case r.Healthy: - return color.GreenString("The cluster is ready") + return color.GreenString(fmt.Sprintf("The cluster '%s' is ready", r.Alias)) case r.Err != nil: - return color.RedString("The cluster is unreachable: " + r.Err.Error()) + return color.RedString(fmt.Sprintf("The cluster '%s' is unreachable: %s", r.Alias, r.Err.Error())) default: - return color.RedString("The cluster is not ready") + return color.RedString(fmt.Sprintf("The cluster '%s' is not ready", r.Alias)) } } @@ -132,6 +135,8 @@ func mainReady(cliCtx *cli.Context) error { case <-timer.C: healthResult, hErr := anonClient.Healthy(ctx, healthOpts) printMsg(readyMessage{ + Alias: aliasedURL, + Status: "success", Healthy: healthResult.Healthy, MaintenanceMode: healthResult.MaintenanceMode, WriteQuorum: healthResult.WriteQuorum,