Skip to content

Conversation

@smacker
Copy link
Contributor

@smacker smacker commented Jun 20, 2019

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

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>
@smacker smacker requested a review from a team June 20, 2019 12:59
Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,40 @@
package subcmd
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+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)

@smacker
Copy link
Contributor Author

smacker commented Jun 21, 2019

No need right now. Move to to-do to come back to it after release.

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.

3 participants