diff --git a/github/actions_artifacts.go b/github/actions_artifacts.go index 016ce7a121d..7fe534951ff 100644 --- a/github/actions_artifacts.go +++ b/github/actions_artifacts.go @@ -131,10 +131,10 @@ func (s *ActionsService) getDownloadArtifactFromURL(ctx context.Context, u strin var resp *http.Response // Use http.DefaultTransport if no custom Transport is configured req = withContext(ctx, req) - if s.client.client.Transport == nil { + if s.client.Client.Transport == nil { resp, err = http.DefaultTransport.RoundTrip(req) } else { - resp, err = s.client.client.Transport.RoundTrip(req) + resp, err = s.client.Client.Transport.RoundTrip(req) } if err != nil { return nil, err diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index e526e059714..62479dfcbaf 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -297,7 +297,7 @@ func TestActionsSerivice_DownloadArtifact(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.Client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { return nil, errors.New("failed to download artifact") }) testBadOptions(t, methodName, func() (err error) { diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 1102a756a54..c83d54d17c3 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -129,10 +129,10 @@ func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, f var resp *http.Response // Use http.DefaultTransport if no custom Transport is configured req = withContext(ctx, req) - if s.client.client.Transport == nil { + if s.client.Client.Transport == nil { resp, err = http.DefaultTransport.RoundTrip(req) } else { - resp, err = s.client.client.Transport.RoundTrip(req) + resp, err = s.client.Client.Transport.RoundTrip(req) } if err != nil { return nil, err diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 49315a03ba4..2f95364bd72 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -157,7 +157,7 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.Client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { return nil, errors.New("failed to get workflow logs") }) testBadOptions(t, methodName, func() (err error) { diff --git a/github/github.go b/github/github.go index ae0ee08c838..d734fca8eb5 100644 --- a/github/github.go +++ b/github/github.go @@ -137,7 +137,7 @@ var errNonNilContext = errors.New("context must be non-nil") // A Client manages communication with the GitHub API. type Client struct { clientMu sync.Mutex // clientMu protects the client during calls that modify the CheckRedirect func. - client *http.Client // HTTP client used to communicate with the API. + Client *http.Client // HTTP client used to communicate with the API. // Base URL for API requests. Defaults to the public GitHub API, but can be // set to a domain endpoint to use with GitHub Enterprise. BaseURL should @@ -273,7 +273,7 @@ func NewClient(httpClient *http.Client) *Client { baseURL, _ := url.Parse(defaultBaseURL) uploadURL, _ := url.Parse(uploadBaseURL) - c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL} + c := &Client{Client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL} c.common.client = c c.Actions = (*ActionsService)(&c.common) c.Activity = (*ActivityService)(&c.common) @@ -575,7 +575,7 @@ func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, erro } } - resp, err := c.client.Do(req) + resp, err := c.Client.Do(req) if err != nil { // If we got an error, and the context has been canceled, // the context's error is probably more useful. diff --git a/github/github_test.go b/github/github_test.go index 1eb0dba7337..4647e930754 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -227,7 +227,7 @@ func TestNewClient(t *testing.T) { } c2 := NewClient(nil) - if c.client == c2.client { + if c.Client == c2.Client { t.Error("NewClient returned same http.Clients, but they should differ") } } diff --git a/github/migrations.go b/github/migrations.go index 7694021f1fb..2efba96a766 100644 --- a/github/migrations.go +++ b/github/migrations.go @@ -172,12 +172,12 @@ func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, // Disable the redirect mechanism because AWS fails if the GitHub auth token is provided. var loc string - saveRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + saveRedirect := s.client.Client.CheckRedirect + s.client.Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { loc = req.URL.String() return errors.New("disable redirect") } - defer func() { s.client.client.CheckRedirect = saveRedirect }() + defer func() { s.client.Client.CheckRedirect = saveRedirect }() _, err = s.client.Do(ctx, req, nil) // expect error from disable redirect if err == nil { diff --git a/github/migrations_user.go b/github/migrations_user.go index 5e8aaec5aa5..cbee2110221 100644 --- a/github/migrations_user.go +++ b/github/migrations_user.go @@ -159,13 +159,13 @@ func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64 m := &UserMigration{} var loc string - originalRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + originalRedirect := s.client.Client.CheckRedirect + s.client.Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { loc = req.URL.String() return http.ErrUseLastResponse } defer func() { - s.client.client.CheckRedirect = originalRedirect + s.client.Client.CheckRedirect = originalRedirect }() resp, err := s.client.Do(ctx, req, m) if err == nil { diff --git a/github/repos.go b/github/repos.go index eaadbb43753..14d0a8b9799 100644 --- a/github/repos.go +++ b/github/repos.go @@ -972,10 +972,10 @@ func (s *RepositoriesService) getBranchFromURL(ctx context.Context, u string, fo var resp *http.Response // Use http.DefaultTransport if no custom Transport is configured req = withContext(ctx, req) - if s.client.client.Transport == nil { + if s.client.Client.Transport == nil { resp, err = http.DefaultTransport.RoundTrip(req) } else { - resp, err = s.client.client.Transport.RoundTrip(req) + resp, err = s.client.Client.Transport.RoundTrip(req) } if err != nil { return nil, err diff --git a/github/repos_contents.go b/github/repos_contents.go index d88ae74b393..1bd656f742e 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -134,7 +134,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, resp, fmt.Errorf("No download link found for %s", filepath) } - dlResp, err := s.client.client.Get(*contents.DownloadURL) + dlResp, err := s.client.Client.Get(*contents.DownloadURL) if err != nil { return nil, &Response{Response: dlResp}, err } @@ -164,7 +164,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, contents, resp, fmt.Errorf("No download link found for %s", filepath) } - dlResp, err := s.client.client.Get(*contents.DownloadURL) + dlResp, err := s.client.Client.Get(*contents.DownloadURL) if err != nil { return nil, contents, &Response{Response: dlResp}, err } @@ -304,10 +304,10 @@ func (s *RepositoriesService) getArchiveLinkFromURL(ctx context.Context, u strin var resp *http.Response // Use http.DefaultTransport if no custom Transport is configured req = withContext(ctx, req) - if s.client.client.Transport == nil { + if s.client.Client.Transport == nil { resp, err = http.DefaultTransport.RoundTrip(req) } else { - resp, err = s.client.client.Transport.RoundTrip(req) + resp, err = s.client.Client.Transport.RoundTrip(req) } if err != nil { return nil, err diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index befb2fadff9..222ede8f5a0 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -694,7 +694,7 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.Client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { return nil, errors.New("failed to get archive link") }) testBadOptions(t, methodName, func() (err error) { diff --git a/github/repos_releases.go b/github/repos_releases.go index f7b03f2e2a1..a22fa5b9ffe 100644 --- a/github/repos_releases.go +++ b/github/repos_releases.go @@ -289,15 +289,15 @@ func (s *RepositoriesService) DownloadReleaseAsset(ctx context.Context, owner, r defer s.client.clientMu.Unlock() var loc string - saveRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + saveRedirect := s.client.Client.CheckRedirect + s.client.Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { loc = req.URL.String() return errors.New("disable redirect") } - defer func() { s.client.client.CheckRedirect = saveRedirect }() + defer func() { s.client.Client.CheckRedirect = saveRedirect }() req = withContext(ctx, req) - resp, err := s.client.client.Do(req) + resp, err := s.client.Client.Do(req) if err != nil { if !strings.Contains(err.Error(), "disable redirect") { return nil, "", err diff --git a/github/repos_test.go b/github/repos_test.go index 4bb6be22a56..cf50635d3f5 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -970,7 +970,7 @@ func TestRepositoriesService_GetBranch_notFound(t *testing.T) { } // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.Client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { return nil, errors.New("failed to get branch") })