defaultGithubClient returns a OAuth scoped Github API Client if GITHUB_TOKEN is set the local environment, or an unauthorized one otherwise.
()
| 57 | // defaultGithubClient returns a OAuth scoped Github API Client if GITHUB_TOKEN |
| 58 | // is set the local environment, or an unauthorized one otherwise. |
| 59 | func defaultGithubClient() *github.Client { |
| 60 | token, ok := os.LookupEnv("GITHUB_TOKEN") |
| 61 | if ok { |
| 62 | ctx := context.Background() |
| 63 | ts := oauth2.StaticTokenSource( |
| 64 | &oauth2.Token{AccessToken: token}, |
| 65 | ) |
| 66 | tc := oauth2.NewClient(ctx, ts) |
| 67 | return github.NewClient(tc) |
| 68 | } |
| 69 | return github.NewClient(nil) |
| 70 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…