Skip to content

Commit 3a70155

Browse files
committed
refactor: Rename body parameters
1 parent 0eacd34 commit 3a70155

116 files changed

Lines changed: 1167 additions & 479 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.

.custom-gcl.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ plugins:
66
path: ./tools/fmtpercentv
77
- module: "github.com/google/go-github/v88/tools/redundantptr"
88
path: ./tools/redundantptr
9+
- module: "github.com/google/go-github/v88/tools/requestbody"
10+
path: ./tools/requestbody
911
- module: "github.com/google/go-github/v88/tools/sliceofpointers"
1012
path: ./tools/sliceofpointers
1113
- module: "github.com/google/go-github/v88/tools/structfield"

.golangci.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ linters:
2828
- paralleltest
2929
- perfsprint
3030
- redundantptr
31+
- requestbody
3132
- revive
3233
- sliceofpointers
3334
- staticcheck
@@ -198,6 +199,134 @@ linters:
198199
type: module
199200
description: Reports github.Ptr(x) calls that can be replaced with &x.
200201
original-url: github.com/google/go-github/v88/tools/redundantptr
202+
requestbody:
203+
type: module
204+
description: Reports miscellaneous issues for request body parameters.
205+
original-url: github.com/google/go-github/v88/tools/requestbody
206+
settings:
207+
# Body type names exempt from the "pass by value, not by pointer" rule.
208+
# TODO: fix and remove these exceptions.
209+
allowed-pointer-types:
210+
- ActionsVariable
211+
- AddProjectItemOptions
212+
- AuthorizationRequest
213+
- AutolinkOptions
214+
- CodeScanningAlertState
215+
- CodespaceCreateForUserOptions
216+
- ConfigApplyOptions
217+
- ConfigSettings
218+
- CreateCodespaceOptions
219+
- CreateOrUpdateCustomRepoRoleOptions
220+
- CreateOrUpdateIssueTypesOptions
221+
- CreateOrgInvitationOptions
222+
- CreateUpdateEnvironment
223+
- CreateWorkflowDispatchEventRequest
224+
- CustomDeploymentProtectionRuleRequest
225+
- CustomProperty
226+
- DependabotAlertState
227+
- DependabotEncryptedSecret
228+
- DependencyGraphSnapshot
229+
- DeploymentBranchPolicyRequest
230+
- DeploymentRequest
231+
- DeploymentStatusRequest
232+
- EncryptedSecret
233+
- EnterpriseSecurityAnalysisSettings
234+
- ExternalGroup
235+
- GenerateJITConfigRequest
236+
- GenerateNotesOptions
237+
- Gist
238+
- GistComment
239+
- Hook
240+
- HookConfig
241+
- ImpersonateUserOptions
242+
- Import
243+
- InstallationTokenListRepoOptions
244+
- InstallationTokenOptions
245+
- IssueComment
246+
- IssueImportRequest
247+
- IssueRequest
248+
- Key
249+
- Label
250+
- LockIssueOptions
251+
- MaintenanceOptions
252+
- Milestone
253+
- NewPullRequest
254+
- OIDCSubjectClaimCustomTemplate
255+
- Organization
256+
- PagesUpdate
257+
- PagesUpdateWithoutCNAME
258+
- PendingDeploymentsRequest
259+
- PreReceiveHook
260+
- ProtectionRequest
261+
- PublishCodespaceOptions
262+
- PullRequestBranchUpdateOptions
263+
- PullRequestComment
264+
- PullRequestReviewDismissalRequest
265+
- PullRequestReviewRequest
266+
- PullRequestReviewsEnforcementUpdate
267+
- ReleaseAsset
268+
- RepoMergeUpstreamRequest
269+
- Repository
270+
- RepositoryAddCollaboratorOptions
271+
- RepositoryComment
272+
- RepositoryContentFileOptions
273+
- RepositoryCreateForkOptions
274+
- RepositoryMergeRequest
275+
- RequiredStatusChecksRequest
276+
- ReviewCustomDeploymentProtectionRuleRequest
277+
- SCIMUserAttributes
278+
- SarifAnalysis
279+
- SecretScanningAlertUpdateOptions
280+
- SecretScanningPatternConfigsUpdateOptions
281+
- SourceImportAuthor
282+
- Subscription
283+
- TeamAddTeamMembershipOptions
284+
- TeamAddTeamRepoOptions
285+
- TeamLDAPMapping
286+
- TeamProjectOptions
287+
- TemplateRepoRequest
288+
- UpdateCodespaceOptions
289+
- UpdateDefaultSetupConfigurationOptions
290+
- UpdateProjectItemOptions
291+
- User
292+
- UserLDAPMapping
293+
- UserSuspendOptions
294+
- WorkflowsPermissionsOpt
295+
# Body type names exempt from the "Options" suffix rule.
296+
# TODO: fix and remove these exceptions.
297+
allowed-wrong-names:
298+
- AddProjectItemOptions
299+
- AutolinkOptions
300+
- CheckSuitePreferenceOptions
301+
- CodespaceCreateForUserOptions
302+
- ConfigApplyOptions
303+
- CreateCheckRunOptions
304+
- CreateCheckSuiteOptions
305+
- CreateCodespaceOptions
306+
- CreateOrUpdateCustomRepoRoleOptions
307+
- CreateOrUpdateIssueTypesOptions
308+
- CreateOrgInvitationOptions
309+
- GenerateNotesOptions
310+
- ImpersonateUserOptions
311+
- InstallationTokenListRepoOptions
312+
- InstallationTokenOptions
313+
- LockIssueOptions
314+
- MaintenanceOptions
315+
- PublishCodespaceOptions
316+
- PullRequestBranchUpdateOptions
317+
- RepositoryAddCollaboratorOptions
318+
- RepositoryContentFileOptions
319+
- RepositoryCreateForkOptions
320+
- SecretScanningAlertUpdateOptions
321+
- SecretScanningPatternConfigsUpdateOptions
322+
- TeamAddTeamMembershipOptions
323+
- TeamAddTeamRepoOptions
324+
- TeamProjectOptions
325+
- UpdateCheckRunOptions
326+
- UpdateCodespaceOptions
327+
- UpdateDefaultSetupConfigurationOptions
328+
- UpdateProjectItemOptions
329+
- UserSuspendOptions
201330
sliceofpointers:
202331
type: module
203332
description: Reports usage of []*string and slices of structs without pointers.
@@ -436,6 +565,8 @@ linters:
436565
issues:
437566
max-issues-per-linter: 0
438567
max-same-issues: 0
568+
# requestbody reports multiple distinct issues on the same parameter line.
569+
uniq-by-line: false
439570
formatters:
440571
enable:
441572
- gci

github/actions_hosted_runners.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ func validateCreateHostedRunnerRequest(request *CreateHostedRunnerRequest) error
140140
// GitHub API docs: https://docs.github.com/rest/actions/hosted-runners?apiVersion=2022-11-28#create-a-github-hosted-runner-for-an-organization
141141
//
142142
//meta:operation POST /orgs/{org}/actions/hosted-runners
143-
func (s *ActionsService) CreateHostedRunner(ctx context.Context, org string, request CreateHostedRunnerRequest) (*HostedRunner, *Response, error) {
144-
if err := validateCreateHostedRunnerRequest(&request); err != nil {
143+
func (s *ActionsService) CreateHostedRunner(ctx context.Context, org string, body CreateHostedRunnerRequest) (*HostedRunner, *Response, error) {
144+
if err := validateCreateHostedRunnerRequest(&body); err != nil {
145145
return nil, nil, fmt.Errorf("validation failed: %w", err)
146146
}
147147

148148
u := fmt.Sprintf("orgs/%v/actions/hosted-runners", org)
149-
req, err := s.client.NewRequest(ctx, "POST", u, request)
149+
req, err := s.client.NewRequest(ctx, "POST", u, body)
150150
if err != nil {
151151
return nil, nil, err
152152
}
@@ -362,9 +362,9 @@ func (s *ActionsService) GetHostedRunner(ctx context.Context, org string, runner
362362
// GitHub API docs: https://docs.github.com/rest/actions/hosted-runners?apiVersion=2022-11-28#update-a-github-hosted-runner-for-an-organization
363363
//
364364
//meta:operation PATCH /orgs/{org}/actions/hosted-runners/{hosted_runner_id}
365-
func (s *ActionsService) UpdateHostedRunner(ctx context.Context, org string, runnerID int64, request UpdateHostedRunnerRequest) (*HostedRunner, *Response, error) {
365+
func (s *ActionsService) UpdateHostedRunner(ctx context.Context, org string, runnerID int64, body UpdateHostedRunnerRequest) (*HostedRunner, *Response, error) {
366366
u := fmt.Sprintf("orgs/%v/actions/hosted-runners/%v", org, runnerID)
367-
req, err := s.client.NewRequest(ctx, "PATCH", u, request)
367+
req, err := s.client.NewRequest(ctx, "PATCH", u, body)
368368
if err != nil {
369369
return nil, nil, err
370370
}

github/actions_oidc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Conte
7171
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template)
7272
}
7373

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

github/actions_permissions_enterprise.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ func (s *ActionsService) GetActionsPermissionsInEnterprise(ctx context.Context,
7373
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-github-actions-permissions-for-an-enterprise
7474
//
7575
//meta:operation PUT /enterprises/{enterprise}/actions/permissions
76-
func (s *ActionsService) UpdateActionsPermissionsInEnterprise(ctx context.Context, enterprise string, actionsPermissionsEnterprise ActionsPermissionsEnterprise) (*ActionsPermissionsEnterprise, *Response, error) {
76+
func (s *ActionsService) UpdateActionsPermissionsInEnterprise(ctx context.Context, enterprise string, body ActionsPermissionsEnterprise) (*ActionsPermissionsEnterprise, *Response, error) {
7777
u := fmt.Sprintf("enterprises/%v/actions/permissions", enterprise)
78-
req, err := s.client.NewRequest(ctx, "PUT", u, actionsPermissionsEnterprise)
78+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
7979
if err != nil {
8080
return nil, nil, err
8181
}
@@ -207,9 +207,9 @@ func (s *ActionsService) GetActionsAllowedInEnterprise(ctx context.Context, ente
207207
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-allowed-actions-and-reusable-workflows-for-an-enterprise
208208
//
209209
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/selected-actions
210-
func (s *ActionsService) UpdateActionsAllowedInEnterprise(ctx context.Context, enterprise string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) {
210+
func (s *ActionsService) UpdateActionsAllowedInEnterprise(ctx context.Context, enterprise string, body ActionsAllowed) (*ActionsAllowed, *Response, error) {
211211
u := fmt.Sprintf("enterprises/%v/actions/permissions/selected-actions", enterprise)
212-
req, err := s.client.NewRequest(ctx, "PUT", u, actionsAllowed)
212+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
213213
if err != nil {
214214
return nil, nil, err
215215
}
@@ -250,9 +250,9 @@ func (s *ActionsService) GetDefaultWorkflowPermissionsInEnterprise(ctx context.C
250250
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-default-workflow-permissions-for-an-enterprise
251251
//
252252
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/workflow
253-
func (s *ActionsService) UpdateDefaultWorkflowPermissionsInEnterprise(ctx context.Context, enterprise string, permissions DefaultWorkflowPermissionEnterprise) (*DefaultWorkflowPermissionEnterprise, *Response, error) {
253+
func (s *ActionsService) UpdateDefaultWorkflowPermissionsInEnterprise(ctx context.Context, enterprise string, body DefaultWorkflowPermissionEnterprise) (*DefaultWorkflowPermissionEnterprise, *Response, error) {
254254
u := fmt.Sprintf("enterprises/%v/actions/permissions/workflow", enterprise)
255-
req, err := s.client.NewRequest(ctx, "PUT", u, permissions)
255+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
256256
if err != nil {
257257
return nil, nil, err
258258
}
@@ -293,9 +293,9 @@ func (s *ActionsService) GetArtifactAndLogRetentionPeriodInEnterprise(ctx contex
293293
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-artifact-and-log-retention-settings-for-an-enterprise
294294
//
295295
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/artifact-and-log-retention
296-
func (s *ActionsService) UpdateArtifactAndLogRetentionPeriodInEnterprise(ctx context.Context, enterprise string, period ArtifactPeriodOpt) (*Response, error) {
296+
func (s *ActionsService) UpdateArtifactAndLogRetentionPeriodInEnterprise(ctx context.Context, enterprise string, body ArtifactPeriodOpt) (*Response, error) {
297297
u := fmt.Sprintf("enterprises/%v/actions/permissions/artifact-and-log-retention", enterprise)
298-
req, err := s.client.NewRequest(ctx, "PUT", u, period)
298+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
299299
if err != nil {
300300
return nil, err
301301
}
@@ -329,9 +329,9 @@ func (s *ActionsService) GetSelfHostedRunnerPermissionsInEnterprise(ctx context.
329329
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-self-hosted-runners-permissions-for-an-enterprise
330330
//
331331
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/self-hosted-runners
332-
func (s *ActionsService) UpdateSelfHostedRunnerPermissionsInEnterprise(ctx context.Context, enterprise string, permissions SelfHostRunnerPermissionsEnterprise) (*Response, error) {
332+
func (s *ActionsService) UpdateSelfHostedRunnerPermissionsInEnterprise(ctx context.Context, enterprise string, body SelfHostRunnerPermissionsEnterprise) (*Response, error) {
333333
u := fmt.Sprintf("enterprises/%v/actions/permissions/self-hosted-runners", enterprise)
334-
req, err := s.client.NewRequest(ctx, "PUT", u, permissions)
334+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
335335
if err != nil {
336336
return nil, err
337337
}
@@ -366,9 +366,9 @@ func (s *ActionsService) GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx co
366366
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-private-repo-fork-pr-workflow-settings-for-an-enterprise
367367
//
368368
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/fork-pr-workflows-private-repos
369-
func (s *ActionsService) UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, permissions *WorkflowsPermissionsOpt) (*Response, error) {
369+
func (s *ActionsService) UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, body *WorkflowsPermissionsOpt) (*Response, error) {
370370
u := fmt.Sprintf("enterprises/%v/actions/permissions/fork-pr-workflows-private-repos", enterprise)
371-
req, err := s.client.NewRequest(ctx, "PUT", u, permissions)
371+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
372372
if err != nil {
373373
return nil, err
374374
}
@@ -403,9 +403,9 @@ func (s *ActionsService) GetEnterpriseForkPRContributorApprovalPermissions(ctx c
403403
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions?apiVersion=2022-11-28#set-fork-pr-contributor-approval-permissions-for-an-enterprise
404404
//
405405
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/fork-pr-contributor-approval
406-
func (s *ActionsService) UpdateEnterpriseForkPRContributorApprovalPermissions(ctx context.Context, enterprise string, policy ContributorApprovalPermissions) (*Response, error) {
406+
func (s *ActionsService) UpdateEnterpriseForkPRContributorApprovalPermissions(ctx context.Context, enterprise string, body ContributorApprovalPermissions) (*Response, error) {
407407
u := fmt.Sprintf("enterprises/%v/actions/permissions/fork-pr-contributor-approval", enterprise)
408-
req, err := s.client.NewRequest(ctx, "PUT", u, policy)
408+
req, err := s.client.NewRequest(ctx, "PUT", u, body)
409409
if err != nil {
410410
return nil, err
411411
}

0 commit comments

Comments
 (0)