From 2e95a70c98fb9c2629cd89817b8759bfa109a4d0 Mon Sep 17 00:00:00 2001 From: Kanagaraj M Date: Sun, 29 Jan 2023 01:59:38 +0530 Subject: [PATCH] Use --api-key flag on register when provided (#4458) --- cmd/license-register.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/license-register.go b/cmd/license-register.go index e6525fdf..76a5faf4 100644 --- a/cmd/license-register.go +++ b/cmd/license-register.go @@ -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"