Use --api-key flag on register when provided (#4458)

This commit is contained in:
Kanagaraj M
2023-01-28 12:29:38 -08:00
committed by GitHub
parent 58b7fc447d
commit 246be3a763
+11 -6
View File
@@ -170,13 +170,18 @@ func mainLicenseRegister(ctx *cli.Context) error {
regInfo := getClusterRegInfo(getAdminInfo(aliasedURL), clusterName)
alreadyRegistered := false
apiKey, _, e := getSubnetCreds(alias)
fatalIf(probe.NewError(e), "Error in fetching subnet API Key")
if len(apiKey) > 0 {
alreadyRegistered = true
if len(accAPIKey) == 0 {
if len(accAPIKey) == 0 {
apiKey, _, e := getSubnetCreds(alias)
fatalIf(probe.NewError(e), "Error in fetching subnet API Key")
if len(apiKey) > 0 {
alreadyRegistered = true
accAPIKey = apiKey
}
} else {
apiKey := getSubnetAPIKeyFromConfig(alias)
if len(apiKey) > 0 {
alreadyRegistered = true
}
}
lrm := licRegisterMessage{Status: "success", Alias: alias}
@@ -189,7 +194,7 @@ func mainLicenseRegister(ctx *cli.Context) error {
lrm.URL = subnetOfflineRegisterURL(regToken)
} else {
lrm.Type = "online"
_, _, e = registerClusterOnSubnet(regInfo, alias, accAPIKey)
_, _, e := registerClusterOnSubnet(regInfo, alias, accAPIKey)
fatalIf(probe.NewError(e), "Could not register cluster with SUBNET:")
lrm.Action = "registered"