Sourcegraph: Make GitHub client package obey the same conventions as the GitLab client package

Created on 11 Mar 2019  路  4Comments  路  Source: sourcegraph/sourcegraph

The GitLab client package, extsvc/gitlab, has two types, ClientProvider and Client. The former produces the latter, and the latter is associated with a specific user identity. The authz/gitlab package relies on the latter to compute permissions for a given user.

Meanwhile, the GitHub client package, extsvc/github, has only a Client type, which has a "base" token. Certain methods of Client allow specifying an override access token. These methods are used by the authz/github package to compute permissions for a given user. There are two issues with the GitHub client package:

  • Not all Client methods support the override user token, meaning inconsistency in the API.
  • The override token is bug-prone and there are caching constraints that might be easily broken in the future (i.e., cache entries should not be shared across different user identities).

We should update extsvc/github to use the ClientProvider + Client pattern used in extsvc/gitlab.

debt teacloud

Most helpful comment

It didn鈥檛 support GraphQL at the time and it was overkill for the 1 API request we needed. I have no opinion or knowledge about whether it鈥檚 a good choice now.

Beyang edit: recommended GraphQL client is https://github.com/shurcooL/githubv4

All 4 comments

Additionally we should probably look into using https://github.com/google/go-github again.

Does anyone recall the rational for not using go-github?

It didn鈥檛 support GraphQL at the time and it was overkill for the 1 API request we needed. I have no opinion or knowledge about whether it鈥檚 a good choice now.

Beyang edit: recommended GraphQL client is https://github.com/shurcooL/githubv4

I don't think this is super relevant anymore, so closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KattMingMing picture KattMingMing  路  3Comments

ryan-blunden picture ryan-blunden  路  3Comments

ryan-blunden picture ryan-blunden  路  3Comments

felixfbecker picture felixfbecker  路  4Comments

keegancsmith picture keegancsmith  路  4Comments