1
0
mirror of https://github.com/minio/mc.git synced 2025-12-11 22:37:25 +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:
Shireesh Anjal
2022-06-11 03:42:40 +05:30
committed by GitHub
parent 50669cafa6
commit 7a6a43046c
2 changed files with 34 additions and 9 deletions

View File

@@ -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()