func InitClient(token string) { var auth octokit.AuthMethod if token != "" { auth = octokit.TokenAuth{token} } internal = octokit.NewClientWith("https://api.github.com", "gh-rel-dashboard", auth, nil) }
// Authenticate authenticates and returns GitHub API Client. func Authenticate() *octokit.Client { config := github.CurrentConfig().Find("github.com") if config == nil { panic("No github.com config found in Hub.") } tokenAuth := octokit.TokenAuth{AccessToken: config.AccessToken} return octokit.NewClientWith( "https://api.github.com", "Hub", tokenAuth, &http.Client{}) }
func Setup() { mux = http.NewServeMux() server = httptest.NewServer(mux) serverURL, _ := url.Parse(server.URL) Client = octokit.NewClientWith( serverURL.String(), "test user agent", octokit.TokenAuth{AccessToken: "token"}, nil, ) }
func (client *Client) newOctokitClient(auth octokit.AuthMethod) *octokit.Client { var host string if client.Host != nil { host = client.Host.Host } host = normalizeHost(host) apiHostURL := client.absolute(host) httpClient := newHttpClient(os.Getenv("HUB_TEST_HOST"), os.Getenv("HUB_VERBOSE") != "") c := octokit.NewClientWith(apiHostURL.String(), UserAgent, auth, httpClient) return c }
func setup(gitHubAPIURL, userAgent, accessToken string) *octokit.Client { httpClient := http.Client{ Transport: http.DefaultTransport, } // octokit client configured client := octokit.NewClientWith( gitHubAPIURL, userAgent, octokit.TokenAuth{AccessToken: accessToken}, &httpClient, ) return client }
func setupGitHubFetcherTest() { // test server mux = http.NewServeMux() server = httptest.NewServer(mux) serverURL, _ := url.Parse(server.URL) httpClient := http.Client{ Transport: TestTransport{ RoundTripper: http.DefaultTransport, overrideURL: serverURL, }, } // octokit client configured to use test server client = octokit.NewClientWith( gitHubAPIURL, userAgent, octokit.TokenAuth{AccessToken: "token"}, &httpClient, ) }