Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI-35: include tenant name, if it is set, when rendering command failures. #107

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

rene00
Copy link
Contributor

@rene00 rene00 commented Feb 23, 2021

Description

Include the tenant name when rendering a command failure:

With no tenant set in config file:

$ auth0 logs

=== error

 ▸    Not yet configured. Try `auth0 login`.

With a tenant set but token has expired or is invalid:

$ auth0 logs

=== cero error

 ▸    401 Unauthorized: Expired token received for JSON Web Token validation

$ auth0 logs
go build -o auth0 cmd/auth0/main.go

=== cero error

 ▸    401 Unauthorized: Invalid token

And with an artificial error injected:

$ git diff
diff --git a/internal/cli/logs.go b/internal/cli/logs.go
index e0ccfb8..9ecfd19 100644
--- a/internal/cli/logs.go
+++ b/internal/cli/logs.go
@@ -1,6 +1,7 @@
 package cli

 import (
+       "errors"
        "fmt"
        "sort"
        "time"
@@ -44,6 +45,7 @@ Show the tenant logs.
                RunE: func(cmd *cobra.Command, args []string) error {
                        lastLogID := ""
                        list, err := getLatestLogs(cli, flags.Num)
+                       err = errors.New("fake error")
                        if err != nil {
                                return err
                        }
$ auth0 logs

=== cero error

 ▸    fake error

References

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@rene00 rene00 self-assigned this Feb 23, 2021
@rene00 rene00 marked this pull request as ready for review February 23, 2021 00:12
@rene00 rene00 requested a review from a team February 23, 2021 00:12
Copy link
Contributor

@cyx cyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I assume the cero refs there are from local testing and not anywhere in the repo?

@rene00
Copy link
Contributor Author

rene00 commented Feb 23, 2021

Looks great!

Thanks,

I assume the cero refs there are from local testing and not anywhere in the repo?

Yes, cero is the name of my tenant defined in ~/.config/auth0/config.json:

$ cat ~/.config/auth0/config.json
{
    "default_tenant": "cero",
    "tenants": {
        "cero": {
            "name": "cero"
[...]

@rene00 rene00 merged commit f32f8e6 into main Feb 23, 2021
@rene00 rene00 deleted the cli-35-tenant-name branch February 23, 2021 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants