diff --git a/go.mod b/go.mod index 42903280a..8eba3877f 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( github.com/bits-and-blooms/bloom/v3 v3.3.1 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/client9/misspell v0.3.4 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect diff --git a/go.sum b/go.sum index 35c16ef90..1481450a9 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/internal/install/command.go b/internal/install/command.go index bdf35c5ba..610d2b6aa 100644 --- a/internal/install/command.go +++ b/internal/install/command.go @@ -113,6 +113,7 @@ func validateProfile(maxTimeoutSeconds int, sg *segment.Segment) *types.DetailEr accountID := configAPI.GetActiveProfileAccountID() APIKey := configAPI.GetActiveProfileString(config.APIKey) region := configAPI.GetActiveProfileString(config.Region) + licenseKey := configAPI.GetActiveProfileString(config.LicenseKey) errorOccured := false var detailErr *types.DetailError @@ -159,13 +160,16 @@ func validateProfile(maxTimeoutSeconds int, sg *segment.Segment) *types.DetailEr return detailErr } - licenseKey, err := client.FetchLicenseKey(accountID, config.FlagProfileName, &maxTimeoutSeconds) - if err != nil { - errorOccured = true - message := fmt.Sprintf("could not fetch license key for account %d:, license key: %v %s", accountID, utils.Obfuscate(licenseKey), err) - log.Debug(message) - detailErr = types.NewDetailError(types.EventTypes.UnableToFetchLicenseKey, fmt.Sprintf("%s", err)) - return detailErr + if licenseKey == "" { + _licenseKey, err := client.FetchLicenseKey(accountID, config.FlagProfileName, &maxTimeoutSeconds) + if err != nil { + errorOccured = true + message := fmt.Sprintf("could not fetch license key for account %d:, license key: %v %s", accountID, utils.Obfuscate(licenseKey), err) + log.Debug(message) + detailErr = types.NewDetailError(types.EventTypes.UnableToFetchLicenseKey, fmt.Sprintf("%s", err)) + return detailErr + } + licenseKey = _licenseKey } os.Setenv("NEW_RELIC_LICENSE_KEY", licenseKey)