mirror of
https://github.com/minio/mc.git
synced 2025-12-13 10:42:14 +03:00
Improve success message in support register cmd (#4108)
Change the success message on cluster registration to `{alias}
registered successfully`.
When the `mc support register` command is run for an already registered
cluster, show the message `{alias} updated successfully` to indicate
that updated information about the cluster was sent to SUBNET.
This commit is contained in:
@@ -434,18 +434,11 @@ func getSubnetAccID(headers map[string]string) (string, error) {
|
||||
|
||||
// registerClusterOnSubnet - Registers the given cluster on SUBNET
|
||||
func registerClusterOnSubnet(alias string, clusterRegInfo ClusterRegistrationInfo) (string, error) {
|
||||
e := setSubnetProxyFromConfig(alias)
|
||||
apiKey, lic, e := getSubnetCreds(alias)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
apiKey := getSubnetAPIKeyFromConfig(alias)
|
||||
|
||||
lic := ""
|
||||
if len(apiKey) == 0 {
|
||||
lic = getSubnetLicenseFromConfig(alias)
|
||||
}
|
||||
|
||||
regURL, headers, e := subnetURLWithAuth(subnetRegisterURL(), apiKey, lic)
|
||||
if e != nil {
|
||||
return "", e
|
||||
@@ -460,6 +453,22 @@ func registerClusterOnSubnet(alias string, clusterRegInfo ClusterRegistrationInf
|
||||
return subnetPostReq(regURL, reqPayload, headers)
|
||||
}
|
||||
|
||||
func getSubnetCreds(alias string) (string, string, error) {
|
||||
e := setSubnetProxyFromConfig(alias)
|
||||
if e != nil {
|
||||
return "", "", e
|
||||
}
|
||||
|
||||
apiKey := getSubnetAPIKeyFromConfig(alias)
|
||||
|
||||
lic := ""
|
||||
if len(apiKey) == 0 {
|
||||
lic = getSubnetLicenseFromConfig(alias)
|
||||
}
|
||||
|
||||
return apiKey, lic, nil
|
||||
}
|
||||
|
||||
// extractAndSaveAPIKey - extract api key from response and set it in minio config
|
||||
func extractAndSaveAPIKey(alias string, resp string) {
|
||||
subnetAPIKey := gjson.Parse(resp).Get("api_key").String()
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/google/uuid"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
@@ -109,6 +110,7 @@ type SubnetMFAReq struct {
|
||||
}
|
||||
|
||||
func mainSupportRegister(ctx *cli.Context) error {
|
||||
console.SetColor("RegisterSuccessMessage", color.New(color.FgGreen, color.Bold))
|
||||
checkSupportRegisterSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
@@ -138,12 +140,26 @@ func mainSupportRegister(ctx *cli.Context) error {
|
||||
|
||||
regInfo := getClusterRegInfo(admInfo, clusterName)
|
||||
|
||||
alreadyRegistered := false
|
||||
apiKey, lic, e := getSubnetCreds(alias)
|
||||
fatalIf(probe.NewError(e), "Error in fetching subnet credentials")
|
||||
if len(apiKey) > 0 || len(lic) > 0 {
|
||||
alreadyRegistered = true
|
||||
}
|
||||
|
||||
if offline {
|
||||
registerOffline(regInfo, alias)
|
||||
} else {
|
||||
registerOnline(regInfo, alias, clusterName)
|
||||
}
|
||||
console.Infoln(fmt.Sprintln("Cluster", clusterName, "successfully registered on SUBNET."))
|
||||
|
||||
action := "registered"
|
||||
if alreadyRegistered {
|
||||
action = "updated"
|
||||
}
|
||||
|
||||
msg := console.Colorize("RegisterSuccessMessage", fmt.Sprintf("%s %s successfully.", clusterName, action))
|
||||
fmt.Println(msg)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user