GetGitHubClient returns a singleton GitHub client and context, initializing it if necessary.
(withAuth bool)
| 33 | |
| 34 | // GetGitHubClient returns a singleton GitHub client and context, initializing it if necessary. |
| 35 | func GetGitHubClient(withAuth bool) (context.Context, *Client) { |
| 36 | githubClientOnce.Do(func() { |
| 37 | githubContext = context.Background() |
| 38 | // Respect proxies set in the environment |
| 39 | githubClientNoAuth = github.NewClientWithEnvProxy() |
| 40 | githubClient = githubClientNoAuth |
| 41 | githubToken, _ := GetGitHubToken() |
| 42 | if githubToken != "" { |
| 43 | githubClient = githubClient.WithAuthToken(githubToken) |
| 44 | } |
| 45 | }) |
| 46 | if withAuth { |
| 47 | return githubContext, githubClient |
| 48 | } |
| 49 | return githubContext, githubClientNoAuth |
| 50 | } |
| 51 | |
| 52 | // GetGitHubRelease gets the tarball URL and version for a GitHub repository release |
| 53 | func GetGitHubRelease(owner, repo, requestedVersion string) (tarballURL, downloadedRelease string, err error) { |
no test coverage detected