Add validate sub command#46
Open
smacker wants to merge 1 commit intosrc-d:masterfrom
smacker:validate_subcommand
Open
Add validate sub command#46smacker wants to merge 1 commit intosrc-d:masterfrom smacker:validate_subcommand
smacker wants to merge 1 commit intosrc-d:masterfrom
smacker:validate_subcommand
Conversation
Accepts the same arguments as shallow command for a token and list of organizations. To validate the token makes request to `/me` endpoint that doesn't require any special permissions. To validate organizations makes requests to `/orgs/<name>`. Returns human friendly errors in 2 most common cases: - Invalid token (unauthorized error) - Organization doesn't exist For any other errors it returns go-github error as is. Example output: ``` $ ghsync validate --token=not-valid --orgs=src-d,thisorgshouldnotexistforsurebecauseisaidso github token is not valid exit status 1 $ ghsync validate --token=<valid> --orgs=src-d,thisorgshouldnotexistforsurebecauseisaidso organization 'thisorgshouldnotexistforsurebecauseisaidso' is not found exit status 1 $ ghsync validate --token=<valid> --orgs=src-d $ echo $? 0 ``` Ref: src-d/sourced-ce#59 Signed-off-by: Maxim Sukharev <max@smacker.ru>
dpordomingo
reviewed
Jun 20, 2019
| @@ -0,0 +1,40 @@ | |||
| package subcmd | |||
Contributor
There was a problem hiding this comment.
After considering src-d/sourced-ce#66 (comment), I'd do the validation automatically every time the user runs the ShallowCommand::Execute, instead of offering it as a separated command.
Even offering it as a separated command, I'd validate the token/orgs before start fetching data from GH
Contributor
Author
There was a problem hiding this comment.
+1 for running it before sync execution. But maybe we can refactor it somehow to avoid extra calls. (shallow command calls the same endpoints already)
se7entyse7en
approved these changes
Jun 21, 2019
Contributor
Author
|
No need right now. Move to to-do to come back to it after release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accepts the same arguments as shallow command for a token and list of
organizations.
To validate the token makes request to
/meendpoint that doesn'trequire any special permissions.
To validate organizations makes requests to
/orgs/<name>.Returns human friendly errors in 2 most common cases:
For any other errors it returns go-github error as is.
Example output:
Ref: src-d/sourced-ce#59