Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ linters:
- SCIMUserAttributes
- SourceImportAuthor
- Subscription
- UpdateDefaultSetupConfigurationOptions
# Body type names exempt from the "Options" suffix rule.
# TODO: fix and remove these exceptions.
body-allowed-wrong-names:
Expand All @@ -242,7 +241,6 @@ linters:
- MaintenanceOptions
- RepositoryContentFileOptions
- UpdateCheckRunOptions
- UpdateDefaultSetupConfigurationOptions
sliceofpointers:
type: module
description: Reports usage of []*string and slices of structs without pointers.
Expand Down
16 changes: 9 additions & 7 deletions github/code_scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,14 @@ func (s *CodeScanningService) GetDefaultSetupConfiguration(ctx context.Context,
return cfg, resp, nil
}

// UpdateDefaultSetupConfigurationOptions specifies parameters to the CodeScanningService.UpdateDefaultSetupConfiguration
// method.
type UpdateDefaultSetupConfigurationOptions struct {
State string `json:"state"`
QuerySuite *string `json:"query_suite,omitempty"`
Languages []string `json:"languages,omitempty"`
// UpdateDefaultSetupConfigurationRequest represents a request to update a code scanning default setup configuration.
type UpdateDefaultSetupConfigurationRequest struct {
State *string `json:"state,omitempty"`
RunnerType *string `json:"runner_type,omitempty"`
RunnerLabel *string `json:"runner_label,omitempty"`
QuerySuite *string `json:"query_suite,omitempty"`
ThreatModel *string `json:"threat_model,omitempty"`
Languages []string `json:"languages,omitzero"`
}

// UpdateDefaultSetupConfigurationResponse represents a response from updating a code scanning default setup configuration.
Expand All @@ -684,7 +686,7 @@ type UpdateDefaultSetupConfigurationResponse struct {
// GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning?apiVersion=2022-11-28#update-a-code-scanning-default-setup-configuration
//
//meta:operation PATCH /repos/{owner}/{repo}/code-scanning/default-setup
func (s *CodeScanningService) UpdateDefaultSetupConfiguration(ctx context.Context, owner, repo string, body *UpdateDefaultSetupConfigurationOptions) (*UpdateDefaultSetupConfigurationResponse, *Response, error) {
func (s *CodeScanningService) UpdateDefaultSetupConfiguration(ctx context.Context, owner, repo string, body UpdateDefaultSetupConfigurationRequest) (*UpdateDefaultSetupConfigurationResponse, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/default-setup", owner, repo)

req, err := s.client.NewRequest(ctx, "PATCH", u, body)
Expand Down
21 changes: 13 additions & 8 deletions github/code_scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1475,8 +1475,18 @@ func TestCodeScanningService_UpdateDefaultSetupConfiguration(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

body := UpdateDefaultSetupConfigurationRequest{
State: new("configured"),
RunnerType: new("labeled"),
RunnerLabel: new("code-scanning"),
QuerySuite: new("default"),
ThreatModel: new("remote_and_local"),
Languages: []string{"go"},
}

mux.HandleFunc("/repos/o/r/code-scanning/default-setup", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
testJSONBody(t, r, body)
_, err := fmt.Fprint(w, `{
"run_id": 5301214200,
"run_url": "https://api.github.com/repos/o/r/actions/runs/5301214200"
Expand All @@ -1487,12 +1497,7 @@ func TestCodeScanningService_UpdateDefaultSetupConfiguration(t *testing.T) {
})

ctx := t.Context()
options := &UpdateDefaultSetupConfigurationOptions{
State: "configured",
Languages: []string{"go"},
QuerySuite: new("default"),
}
got, _, err := client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "o", "r", options)
got, _, err := client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "o", "r", body)
if err != nil {
t.Errorf("CodeScanning.UpdateDefaultSetupConfiguration returned error: %v", err)
}
Expand All @@ -1507,12 +1512,12 @@ func TestCodeScanningService_UpdateDefaultSetupConfiguration(t *testing.T) {

const methodName = "UpdateDefaultSetupConfiguration"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "\n", "\n", nil)
_, _, err = client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "\n", "\n", UpdateDefaultSetupConfigurationRequest{})
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "o", "r", nil)
got, resp, err := client.CodeScanning.UpdateDefaultSetupConfiguration(ctx, "o", "r", UpdateDefaultSetupConfigurationRequest{})
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down
36 changes: 30 additions & 6 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 44 additions & 8 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading