-
Notifications
You must be signed in to change notification settings - Fork 846
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
fly: tell user when team is invalid #5670
Conversation
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.
Tested it and it seems to work, but the behaviour is a bit different than I would expect.
$ fly -t dev login -c https://127.0.0.1:8080 -u test -p test -n blah
logging in to team 'blah'
target saved
error: you are not a member of 'blah' or the team does not exist
It's weird to say target saved
(and to save the target at all) if the team is invalid. What do you think about the following: instead of calling rc.SaveTarget(...)
to perform the userInfo
check, we instead use rc.NewTarget(...)
, and only after validating the user is a member of the team do we save the target.
EDIT
Perhaps a better way to do this would be to modify target.Validate()
to also perform the user info check, and in fly login
call:
target := rc.NewTarget(...)
err := target.Validate()
if err != nil {
return err
}
err = command.saveTarget(...)
...
This way, we'd also perform the user info check for every command, so if a user is removed from a team, they'd also see an appropriate error message.
@aoldershaw Updated so the target is NOT saved if the user is not on the team/the team doesn't exist.
I joked with @jomsie that this function should really be called |
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.
Logging into an invalid team behaves as expected:
$ fly -t dev login -c https://127.0.0.1:8080 -u test -p test -n blah
logging in to team 'blah'
error: you are not a member of 'blah' or the team does not exist
...as does logging into a valid team:
$ fly -t dev login -c https://127.0.0.1:8080 -u test -p test -n main
logging in to team 'main'
target saved
Looks good!
#5624 Before 6.1.0 fly would exit 1 and display an error if the user logged in with an invalid team. This commit brings back this behaviour. Signed-off-by: Taylor Silva <[email protected]> Co-authored-by: James Thomson <[email protected]>
Instead of saving the target and then verifying team membership we create a NewAuthenticatedTarget() and use it to verify the users membership on the team. If this check fails then we bail out early and never save the target. Signed-off-by: Taylor Silva <[email protected]>
Had to rebase on master to fix release notes conflict. Review again please :) |
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.
Still looks good! (I'm not seeing any changes to the code...let me know if I missed anything)
What does this PR accomplish?
closes #5624
Before 6.1.0 fly would exit 1 and display an error if the user logged in
with an invalid team. This commit brings back this behaviour.
Contributor Checklist
Updated DocumentationReviewer Checklist
BOSH and
Helm packaging; otherwise, ignored for
the integration
tests
(for example, if they are Garden configs that are not displayed in the
--help
text).