From 0d49b009aaf1fba2f4415fbddf2bb64de36ed7ac Mon Sep 17 00:00:00 2001 From: Jeff Mendoza Date: Tue, 15 Feb 2022 15:48:19 -0800 Subject: [PATCH] Add second constructor to allow providing an alreadty authenticated transport. --- clients/githubrepo/client.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/clients/githubrepo/client.go b/clients/githubrepo/client.go index 6b380bf694e..a1ed069c4d6 100644 --- a/clients/githubrepo/client.go +++ b/clients/githubrepo/client.go @@ -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) {