History

Fix activation URL extraction logic and improve warning message formatting

- Corrected JSON path for error code and activation URL extraction in client error handling. - Improved readability of the activation warning message with better spacing.

Luis Pater committed 1 year agov2.4.1

Commit ebcd4db1 parent 1483c311 file · +3 −3Browse files

Unified · Split

internal/client/client.go+3−3
@@ -844,11 +844,11 @@ func (c *Client) CheckCloudAPIIsEnabled() (bool, error) { · 843 unmodified lines
844844 if err.StatusCode == 403 {
845845 errJSON := err.Error.Error()
846846 // Check for a specific error code and extract the activation URL.
847− if gjson.Get(errJSON, "error.code").Int() == 403 {
848− activationURL := gjson.Get(errJSON, "error.details.0.metadata.activationUrl").String()
847+ if gjson.Get(errJSON, "0.error.code").Int() == 403 {
848+ activationURL := gjson.Get(errJSON, "0.error.details.0.metadata.activationUrl").String()
849849 if activationURL != "" {
850850 log.Warnf(
851− "\n\nPlease activate your account with this url:\n\n%s\n And execute this command again:\n%s --login --project_id %s",
851+ "\n\nPlease activate your account with this url:\n\n%s\n\n And execute this command again:\n%s --login --project_id %s",
852852 activationURL,
853853 os.Args[0],
854854 c.tokenStorage.ProjectID,