Skip to content

Commit 691467f

Browse files
committed
feat!: Refactor request context
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
1 parent 44908ea commit 691467f

185 files changed

Lines changed: 1216 additions & 1329 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Every exported method and type needs to have code comments that follow
164164
//meta:operation GET /repos/{owner}/{repo}
165165
func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Repository, *Response, error) {
166166
u := fmt.Sprintf("repos/%v/%v", owner, repo)
167-
req, err := s.client.NewRequest("GET", u, nil)
167+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
168168
...
169169
}
170170
```

example/appengine/app.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

example/appengine/app.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

github/actions_artifacts.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string,
9191
return nil, nil, err
9292
}
9393

94-
req, err := s.client.NewRequest("GET", u, nil)
94+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
9595
if err != nil {
9696
return nil, nil, err
9797
}
@@ -117,7 +117,7 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re
117117
return nil, nil, err
118118
}
119119

120-
req, err := s.client.NewRequest("GET", u, nil)
120+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
121121
if err != nil {
122122
return nil, nil, err
123123
}
@@ -139,7 +139,7 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re
139139
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) {
140140
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
141141

142-
req, err := s.client.NewRequest("GET", u, nil)
142+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
143143
if err != nil {
144144
return nil, nil, err
145145
}
@@ -188,7 +188,7 @@ func (s *ActionsService) downloadArtifactWithoutRateLimit(ctx context.Context, u
188188
}
189189

190190
func (s *ActionsService) downloadArtifactWithRateLimit(ctx context.Context, u string, maxRedirects int) (*url.URL, *Response, error) {
191-
req, err := s.client.NewRequest("GET", u, nil)
191+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
192192
if err != nil {
193193
return nil, nil, err
194194
}
@@ -215,7 +215,7 @@ func (s *ActionsService) downloadArtifactWithRateLimit(ctx context.Context, u st
215215
func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) {
216216
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
217217

218-
req, err := s.client.NewRequest("DELETE", u, nil)
218+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
219219
if err != nil {
220220
return nil, err
221221
}

github/actions_cache.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opt
8787
return nil, nil, err
8888
}
8989

90-
req, err := s.client.NewRequest("GET", u, nil)
90+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
9191
if err != nil {
9292
return nil, nil, err
9393
}
@@ -119,7 +119,7 @@ func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key
119119
return nil, err
120120
}
121121

122-
req, err := s.client.NewRequest("DELETE", u, nil)
122+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
123123
if err != nil {
124124
return nil, err
125125
}
@@ -136,7 +136,7 @@ func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key
136136
//meta:operation DELETE /repos/{owner}/{repo}/actions/caches/{cache_id}
137137
func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo string, cacheID int64) (*Response, error) {
138138
u := fmt.Sprintf("repos/%v/%v/actions/caches/%v", owner, repo, cacheID)
139-
req, err := s.client.NewRequest("DELETE", u, nil)
139+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
140140
if err != nil {
141141
return nil, err
142142
}
@@ -155,7 +155,7 @@ func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo strin
155155
//meta:operation GET /repos/{owner}/{repo}/actions/cache/usage
156156
func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo string) (*ActionsCacheUsage, *Response, error) {
157157
u := fmt.Sprintf("repos/%v/%v/actions/cache/usage", owner, repo)
158-
req, err := s.client.NewRequest("GET", u, nil)
158+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
159159
if err != nil {
160160
return nil, nil, err
161161
}
@@ -185,7 +185,7 @@ func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org str
185185
return nil, nil, err
186186
}
187187

188-
req, err := s.client.NewRequest("GET", u, nil)
188+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
189189
if err != nil {
190190
return nil, nil, err
191191
}
@@ -210,7 +210,7 @@ func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org str
210210
//meta:operation GET /orgs/{org}/actions/cache/usage
211211
func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org string) (*TotalCacheUsage, *Response, error) {
212212
u := fmt.Sprintf("orgs/%v/actions/cache/usage", org)
213-
req, err := s.client.NewRequest("GET", u, nil)
213+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
214214
if err != nil {
215215
return nil, nil, err
216216
}
@@ -234,7 +234,7 @@ func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org strin
234234
//meta:operation GET /enterprises/{enterprise}/actions/cache/usage
235235
func (s *ActionsService) GetTotalCacheUsageForEnterprise(ctx context.Context, enterprise string) (*TotalCacheUsage, *Response, error) {
236236
u := fmt.Sprintf("enterprises/%v/actions/cache/usage", enterprise)
237-
req, err := s.client.NewRequest("GET", u, nil)
237+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
238238
if err != nil {
239239
return nil, nil, err
240240
}

github/actions_hosted_runners.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (s *ActionsService) ListHostedRunners(ctx context.Context, org string, opts
6868
return nil, nil, err
6969
}
7070

71-
req, err := s.client.NewRequest("GET", u, nil)
71+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
7272
if err != nil {
7373
return nil, nil, err
7474
}
@@ -146,7 +146,7 @@ func (s *ActionsService) CreateHostedRunner(ctx context.Context, org string, req
146146
}
147147

148148
u := fmt.Sprintf("orgs/%v/actions/hosted-runners", org)
149-
req, err := s.client.NewRequest("POST", u, request)
149+
req, err := s.client.NewRequest(ctx, "POST", u, request)
150150
if err != nil {
151151
return nil, nil, err
152152
}
@@ -215,7 +215,7 @@ type HostedRunnerImages struct {
215215
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/github-owned
216216
func (s *ActionsService) GetHostedRunnerGitHubOwnedImages(ctx context.Context, org string) (*HostedRunnerImages, *Response, error) {
217217
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/github-owned", org)
218-
req, err := s.client.NewRequest("GET", u, nil)
218+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
219219
if err != nil {
220220
return nil, nil, err
221221
}
@@ -236,7 +236,7 @@ func (s *ActionsService) GetHostedRunnerGitHubOwnedImages(ctx context.Context, o
236236
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/partner
237237
func (s *ActionsService) GetHostedRunnerPartnerImages(ctx context.Context, org string) (*HostedRunnerImages, *Response, error) {
238238
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/partner", org)
239-
req, err := s.client.NewRequest("GET", u, nil)
239+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
240240
if err != nil {
241241
return nil, nil, err
242242
}
@@ -268,7 +268,7 @@ type PublicIPUsage struct {
268268
//meta:operation GET /orgs/{org}/actions/hosted-runners/limits
269269
func (s *ActionsService) GetHostedRunnerLimits(ctx context.Context, org string) (*HostedRunnerPublicIPLimits, *Response, error) {
270270
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/limits", org)
271-
req, err := s.client.NewRequest("GET", u, nil)
271+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
272272
if err != nil {
273273
return nil, nil, err
274274
}
@@ -295,7 +295,7 @@ type HostedRunnerMachineSpecs struct {
295295
//meta:operation GET /orgs/{org}/actions/hosted-runners/machine-sizes
296296
func (s *ActionsService) GetHostedRunnerMachineSpecs(ctx context.Context, org string) (*HostedRunnerMachineSpecs, *Response, error) {
297297
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/machine-sizes", org)
298-
req, err := s.client.NewRequest("GET", u, nil)
298+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
299299
if err != nil {
300300
return nil, nil, err
301301
}
@@ -322,7 +322,7 @@ type HostedRunnerPlatforms struct {
322322
//meta:operation GET /orgs/{org}/actions/hosted-runners/platforms
323323
func (s *ActionsService) GetHostedRunnerPlatforms(ctx context.Context, org string) (*HostedRunnerPlatforms, *Response, error) {
324324
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/platforms", org)
325-
req, err := s.client.NewRequest("GET", u, nil)
325+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
326326
if err != nil {
327327
return nil, nil, err
328328
}
@@ -343,7 +343,7 @@ func (s *ActionsService) GetHostedRunnerPlatforms(ctx context.Context, org strin
343343
//meta:operation GET /orgs/{org}/actions/hosted-runners/{hosted_runner_id}
344344
func (s *ActionsService) GetHostedRunner(ctx context.Context, org string, runnerID int64) (*HostedRunner, *Response, error) {
345345
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/%v", org, runnerID)
346-
req, err := s.client.NewRequest("GET", u, nil)
346+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
347347
if err != nil {
348348
return nil, nil, err
349349
}
@@ -364,7 +364,7 @@ func (s *ActionsService) GetHostedRunner(ctx context.Context, org string, runner
364364
//meta:operation PATCH /orgs/{org}/actions/hosted-runners/{hosted_runner_id}
365365
func (s *ActionsService) UpdateHostedRunner(ctx context.Context, org string, runnerID int64, request UpdateHostedRunnerRequest) (*HostedRunner, *Response, error) {
366366
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/%v", org, runnerID)
367-
req, err := s.client.NewRequest("PATCH", u, request)
367+
req, err := s.client.NewRequest(ctx, "PATCH", u, request)
368368
if err != nil {
369369
return nil, nil, err
370370
}
@@ -385,7 +385,7 @@ func (s *ActionsService) UpdateHostedRunner(ctx context.Context, org string, run
385385
//meta:operation DELETE /orgs/{org}/actions/hosted-runners/{hosted_runner_id}
386386
func (s *ActionsService) DeleteHostedRunner(ctx context.Context, org string, runnerID int64) (*HostedRunner, *Response, error) {
387387
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/%v", org, runnerID)
388-
req, err := s.client.NewRequest("DELETE", u, nil)
388+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
389389
if err != nil {
390390
return nil, nil, err
391391
}
@@ -406,7 +406,7 @@ func (s *ActionsService) DeleteHostedRunner(ctx context.Context, org string, run
406406
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom
407407
func (s *ActionsService) ListHostedRunnerCustomImages(ctx context.Context, org string) (*HostedRunnerCustomImages, *Response, error) {
408408
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom", org)
409-
req, err := s.client.NewRequest("GET", u, nil)
409+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
410410
if err != nil {
411411
return nil, nil, err
412412
}
@@ -427,7 +427,7 @@ func (s *ActionsService) ListHostedRunnerCustomImages(ctx context.Context, org s
427427
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}
428428
func (s *ActionsService) GetHostedRunnerCustomImage(ctx context.Context, org string, imageDefinitionID int64) (*HostedRunnerCustomImage, *Response, error) {
429429
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v", org, imageDefinitionID)
430-
req, err := s.client.NewRequest("GET", u, nil)
430+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
431431
if err != nil {
432432
return nil, nil, err
433433
}
@@ -448,7 +448,7 @@ func (s *ActionsService) GetHostedRunnerCustomImage(ctx context.Context, org str
448448
//meta:operation DELETE /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}
449449
func (s *ActionsService) DeleteHostedRunnerCustomImage(ctx context.Context, org string, imageDefinitionID int64) (*Response, error) {
450450
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v", org, imageDefinitionID)
451-
req, err := s.client.NewRequest("DELETE", u, nil)
451+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
452452
if err != nil {
453453
return nil, err
454454
}
@@ -463,7 +463,7 @@ func (s *ActionsService) DeleteHostedRunnerCustomImage(ctx context.Context, org
463463
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions
464464
func (s *ActionsService) ListHostedRunnerCustomImageVersions(ctx context.Context, org string, imageDefinitionID int64) (*HostedRunnerCustomImageVersions, *Response, error) {
465465
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions", org, imageDefinitionID)
466-
req, err := s.client.NewRequest("GET", u, nil)
466+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
467467
if err != nil {
468468
return nil, nil, err
469469
}
@@ -484,7 +484,7 @@ func (s *ActionsService) ListHostedRunnerCustomImageVersions(ctx context.Context
484484
//meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}
485485
func (s *ActionsService) GetHostedRunnerCustomImageVersion(ctx context.Context, org string, imageDefinitionID int64, version string) (*HostedRunnerCustomImageVersion, *Response, error) {
486486
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions/%v", org, imageDefinitionID, version)
487-
req, err := s.client.NewRequest("GET", u, nil)
487+
req, err := s.client.NewRequest(ctx, "GET", u, nil)
488488
if err != nil {
489489
return nil, nil, err
490490
}
@@ -505,7 +505,7 @@ func (s *ActionsService) GetHostedRunnerCustomImageVersion(ctx context.Context,
505505
//meta:operation DELETE /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}
506506
func (s *ActionsService) DeleteHostedRunnerCustomImageVersion(ctx context.Context, org string, imageDefinitionID int64, version string) (*Response, error) {
507507
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions/%v", org, imageDefinitionID, version)
508-
req, err := s.client.NewRequest("DELETE", u, nil)
508+
req, err := s.client.NewRequest(ctx, "DELETE", u, nil)
509509
if err != nil {
510510
return nil, err
511511
}

github/actions_oidc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (s *ActionsService) GetRepoOIDCSubjectClaimCustomTemplate(ctx context.Conte
3737
}
3838

3939
func (s *ActionsService) getOIDCSubjectClaimCustomTemplate(ctx context.Context, url string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
40-
req, err := s.client.NewRequest("GET", url, nil)
40+
req, err := s.client.NewRequest(ctx, "GET", url, nil)
4141
if err != nil {
4242
return nil, nil, err
4343
}
@@ -72,7 +72,7 @@ func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Conte
7272
}
7373

7474
func (s *ActionsService) setOIDCSubjectClaimCustomTemplate(ctx context.Context, url string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) {
75-
req, err := s.client.NewRequest("PUT", url, template)
75+
req, err := s.client.NewRequest(ctx, "PUT", url, template)
7676
if err != nil {
7777
return nil, err
7878
}

0 commit comments

Comments
 (0)