-
Notifications
You must be signed in to change notification settings - Fork 190
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
boxcli: devbox cache enable #2157
Conversation
Add a `devbox cache enable` subcommand that: 1. Opens a browser and performs the login flow is the user isn't logged in. 2. Configures Nix to use the Jetify cache if it isn't already. The login flow redirects to the new https://cloud.jetify.com/team/cache URL to let the user know the cache is enabled.
if err != nil { | ||
return err | ||
} | ||
sess, _ := auth.GetSessions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want GetSession
?
GetSessions
returned unrefreshed sessions. It's more useful for trying to figure out which session to use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sess, err := auth.GetSession()
needLogin := errors.Is(err, auth.ErrNotLoggedIn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also identity.GenSession
which also uses the API token, but not sure that makes sense for this command?
Long term I think having an API token should be a drop in replacement for logging in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just want to know if the user has logged in before. We don't necessarily need a refreshed token.
I had the same question about whether or not to use the API token. I decided to ignore it, which is why I didn't use identity.Peek
. But now I'm having second thoughts and wondering if we should just remove devbox cache configure
and make devbox cache enable
do everything. Is there ever a situation where it makes sense to configure the cache without having an account or API token?
What if devbox cache enable
did the following:
- If there's a
DEVBOX_API_TOKEN
, skip to step 3. - If the user has never logged in before (no sessions), go through the login flow.
- Configure Nix.
|
||
// AuthRedirectCache redirects to the "Cache" tab in the dashboard for | ||
// the authenticated organization. | ||
AuthRedirectCache = path.Join(build.DashboardHostname(), "team", "cache") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about url in other PR.
Don't merge until the new cloud.jetify.com/team/cache URL is live.
Add a
devbox cache enable
subcommand that:The login flow redirects to the new cloud.jetify.com/team/cache URL to let the user know the cache is enabled.