githubrepo: Allow providing an already authenticated transport (#1644)

This commit is contained in:
Jeff Mendoza 2022-02-15 16:13:45 -08:00 committed by GitHub
parent cda7a1b1d4
commit ba503c3bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -177,10 +177,8 @@ func (client *Client) Close() error {
return client.tarball.cleanup()
}
// CreateGithubRepoClient returns a Client which implements RepoClient interface.
func CreateGithubRepoClient(ctx context.Context, logger *log.Logger) clients.RepoClient {
// Use our custom roundtripper
rt := roundtripper.NewTransport(ctx, logger)
// CreateGithubRepoClientWithTransport returns a Client which implements RepoClient interface.
func CreateGithubRepoClientWithTransport(ctx context.Context, rt http.RoundTripper) clients.RepoClient {
httpClient := &http.Client{
Transport: rt,
}
@ -218,6 +216,13 @@ func CreateGithubRepoClient(ctx context.Context, logger *log.Logger) clients.Rep
}
}
// CreateGithubRepoClient returns a Client which implements RepoClient interface.
func CreateGithubRepoClient(ctx context.Context, logger *log.Logger) clients.RepoClient {
// Use our custom roundtripper
rt := roundtripper.NewTransport(ctx, logger)
return CreateGithubRepoClientWithTransport(ctx, rt)
}
// CreateOssFuzzRepoClient returns a RepoClient implementation
// intialized to `google/oss-fuzz` GitHub repository.
func CreateOssFuzzRepoClient(ctx context.Context, logger *log.Logger) (clients.RepoClient, error) {