Skip to content

Commit

Permalink
add alias name to 'mc ready' (#5044)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Sep 25, 2024
1 parent a5a54b4 commit 97fe232
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cmd/ready.go → cmd/ready-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd

import (
"context"
"fmt"
"time"

"github.com/fatih/color"
Expand Down Expand Up @@ -73,22 +74,24 @@ 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"`
}

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))
}
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 97fe232

Please sign in to comment.