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

Perform token validation as part of 'k6 cloud login' #3930

Merged
merged 5 commits into from
Sep 9, 2024

Conversation

joanlopez
Copy link
Contributor

What?

It performs token validation after as part of k6 cloud login process.

Why?

As discussed in #3886, it's nice to give immediate feedback to users when "logging-in", instead of waiting until they use any other cloud command.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

@joanlopez joanlopez self-assigned this Sep 4, 2024
@joanlopez joanlopez requested a review from a team as a code owner September 4, 2024 08:42
@joanlopez joanlopez requested review from mstoykov, olegbespalov and oleiade and removed request for a team September 4, 2024 08:42
@@ -90,6 +104,9 @@ func (c *cmdCloudLogin) run(cmd *cobra.Command, _ []string) error {
newCloudConf.Token = null.StringFromPtr(nil)
printToStdout(c.globalState, " token reset\n")
case show.Bool:
valueColor := getColor(c.globalState.Flags.NoColor || !c.globalState.Stdout.IsTTY, color.FgCyan)
Copy link
Contributor Author

@joanlopez joanlopez Sep 4, 2024

Choose a reason for hiding this comment

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

I moved these lines here, from the bottom of the file, as I think it only makes sense to print the token when providing the -s flag, as also discussed at #3886.

Otherwise, it doesn't, because:

  • When resetting, with -r, there's no token.
  • When providing it with -t, it's already there.
  • When using the form, we define it as a sensitive field (so it's not displayed while being written).

If we want to show it in the last scenario, I'd just switch the form input type to regular text, otherwise (as it was until now) it is a bit incoherent.

cloudapi/api.go Outdated Show resolved Hide resolved
cloudapi/api.go Outdated Show resolved Hide resolved
cmd/cloud_login.go Outdated Show resolved Hide resolved
oleiade
oleiade previously approved these changes Sep 5, 2024
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

I share most of the comments brought up so far, but consider those potential improvements rather than blockers.

olegbespalov
olegbespalov previously approved these changes Sep 9, 2024
oleiade
oleiade previously approved these changes Sep 9, 2024
mstoykov
mstoykov previously approved these changes Sep 9, 2024
cmd/cloud_login.go Outdated Show resolved Hide resolved
@joanlopez joanlopez added this to the v0.54.0 milestone Sep 9, 2024
@joanlopez joanlopez dismissed stale reviews from mstoykov, oleiade, and olegbespalov via d6ce425 September 9, 2024 12:26
@joanlopez
Copy link
Contributor Author

Hey folks! Sorry for the noise once approved, but I applied the changes suggested by Mihail here at e0de560 🙏🏻

@joanlopez joanlopez added the cloud label Sep 9, 2024
@joanlopez joanlopez merged commit 741610b into master Sep 9, 2024
22 checks passed
@joanlopez joanlopez deleted the validate-token branch September 9, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants