Skip to content

Commit 2fe476f

Browse files
fix: use slices.Concat instead of sometimes modifying r.Options
1 parent 6ff4f7b commit 2fe476f

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

build.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"net/http"
1111
"net/url"
12+
"slices"
1213
"time"
1314

1415
"github.com/stainless-api/stainless-api-go/internal/apijson"
@@ -50,7 +51,7 @@ func NewBuildService(opts ...option.RequestOption) (r BuildService) {
5051
// The project branch will be modified so that its latest set of config files
5152
// points to the one specified by the input revision.
5253
func (r *BuildService) New(ctx context.Context, body BuildNewParams, opts ...option.RequestOption) (res *Build, err error) {
53-
opts = append(r.Options[:], opts...)
54+
opts = slices.Concat(r.Options, opts)
5455
precfg, err := requestconfig.PreRequestOptions(opts...)
5556
if err != nil {
5657
return
@@ -63,7 +64,7 @@ func (r *BuildService) New(ctx context.Context, body BuildNewParams, opts ...opt
6364

6465
// Retrieve a build by its ID.
6566
func (r *BuildService) Get(ctx context.Context, buildID string, opts ...option.RequestOption) (res *Build, err error) {
66-
opts = append(r.Options[:], opts...)
67+
opts = slices.Concat(r.Options, opts)
6768
if buildID == "" {
6869
err = errors.New("missing required buildId parameter")
6970
return
@@ -79,7 +80,7 @@ func (r *BuildService) Get(ctx context.Context, buildID string, opts ...option.R
7980
// of file contents.
8081
func (r *BuildService) List(ctx context.Context, query BuildListParams, opts ...option.RequestOption) (res *pagination.Page[Build], err error) {
8182
var raw *http.Response
82-
opts = append(r.Options[:], opts...)
83+
opts = slices.Concat(r.Options, opts)
8384
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
8485
precfg, err := requestconfig.PreRequestOptions(opts...)
8586
if err != nil {
@@ -117,7 +118,7 @@ func (r *BuildService) ListAutoPaging(ctx context.Context, query BuildListParams
117118
// Builds made via this endpoint are guaranteed to have differences arising from
118119
// the set of config files, and any custom code.
119120
func (r *BuildService) Compare(ctx context.Context, body BuildCompareParams, opts ...option.RequestOption) (res *BuildCompareResponse, err error) {
120-
opts = append(r.Options[:], opts...)
121+
opts = slices.Concat(r.Options, opts)
121122
precfg, err := requestconfig.PreRequestOptions(opts...)
122123
if err != nil {
123124
return

builddiagnostic.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"net/http"
1111
"net/url"
12+
"slices"
1213

1314
"github.com/stainless-api/stainless-api-go/internal/apijson"
1415
"github.com/stainless-api/stainless-api-go/internal/apiquery"
@@ -46,7 +47,7 @@ func NewBuildDiagnosticService(opts ...option.RequestOption) (r BuildDiagnosticS
4647
// returned.
4748
func (r *BuildDiagnosticService) List(ctx context.Context, buildID string, query BuildDiagnosticListParams, opts ...option.RequestOption) (res *pagination.Page[BuildDiagnostic], err error) {
4849
var raw *http.Response
49-
opts = append(r.Options[:], opts...)
50+
opts = slices.Concat(r.Options, opts)
5051
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
5152
if buildID == "" {
5253
err = errors.New("missing required buildId parameter")

buildtargetoutput.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"net/http"
99
"net/url"
10+
"slices"
1011

1112
"github.com/stainless-api/stainless-api-go/internal/apijson"
1213
"github.com/stainless-api/stainless-api-go/internal/apiquery"
@@ -47,7 +48,7 @@ func NewBuildTargetOutputService(opts ...option.RequestOption) (r BuildTargetOut
4748
// and the output method _must_ be `url`. See the documentation for `type` for more
4849
// information.
4950
func (r *BuildTargetOutputService) Get(ctx context.Context, query BuildTargetOutputGetParams, opts ...option.RequestOption) (res *BuildTargetOutputGetResponseUnion, err error) {
50-
opts = append(r.Options[:], opts...)
51+
opts = slices.Concat(r.Options, opts)
5152
path := "v0/build_target_outputs"
5253
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
5354
return

client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"net/http"
88
"os"
9+
"slices"
910

1011
"github.com/stainless-api/stainless-api-go/internal/requestconfig"
1112
"github.com/stainless-api/stainless-api-go/option"
@@ -82,7 +83,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
8283
// For even greater flexibility, see [option.WithResponseInto] and
8384
// [option.WithResponseBodyInto].
8485
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error {
85-
opts = append(r.Options, opts...)
86+
opts = slices.Concat(r.Options, opts)
8687
return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)
8788
}
8889

org.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010
"net/url"
11+
"slices"
1112

1213
"github.com/stainless-api/stainless-api-go/internal/apijson"
1314
"github.com/stainless-api/stainless-api-go/internal/requestconfig"
@@ -36,7 +37,7 @@ func NewOrgService(opts ...option.RequestOption) (r OrgService) {
3637

3738
// Retrieve an organization by name.
3839
func (r *OrgService) Get(ctx context.Context, org string, opts ...option.RequestOption) (res *Org, err error) {
39-
opts = append(r.Options[:], opts...)
40+
opts = slices.Concat(r.Options, opts)
4041
if org == "" {
4142
err = errors.New("missing required org parameter")
4243
return
@@ -48,7 +49,7 @@ func (r *OrgService) Get(ctx context.Context, org string, opts ...option.Request
4849

4950
// List organizations accessible to the current authentication method.
5051
func (r *OrgService) List(ctx context.Context, opts ...option.RequestOption) (res *OrgListResponse, err error) {
51-
opts = append(r.Options[:], opts...)
52+
opts = slices.Concat(r.Options, opts)
5253
path := "v0/orgs"
5354
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
5455
return

project.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010
"net/url"
11+
"slices"
1112

1213
"github.com/stainless-api/stainless-api-go/internal/apijson"
1314
"github.com/stainless-api/stainless-api-go/internal/apiquery"
@@ -44,15 +45,15 @@ func NewProjectService(opts ...option.RequestOption) (r ProjectService) {
4445

4546
// Create a new project.
4647
func (r *ProjectService) New(ctx context.Context, body ProjectNewParams, opts ...option.RequestOption) (res *Project, err error) {
47-
opts = append(r.Options[:], opts...)
48+
opts = slices.Concat(r.Options, opts)
4849
path := "v0/projects"
4950
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
5051
return
5152
}
5253

5354
// Retrieve a project by name.
5455
func (r *ProjectService) Get(ctx context.Context, query ProjectGetParams, opts ...option.RequestOption) (res *Project, err error) {
55-
opts = append(r.Options[:], opts...)
56+
opts = slices.Concat(r.Options, opts)
5657
precfg, err := requestconfig.PreRequestOptions(opts...)
5758
if err != nil {
5859
return
@@ -69,7 +70,7 @@ func (r *ProjectService) Get(ctx context.Context, query ProjectGetParams, opts .
6970

7071
// Update a project's properties.
7172
func (r *ProjectService) Update(ctx context.Context, params ProjectUpdateParams, opts ...option.RequestOption) (res *Project, err error) {
72-
opts = append(r.Options[:], opts...)
73+
opts = slices.Concat(r.Options, opts)
7374
precfg, err := requestconfig.PreRequestOptions(opts...)
7475
if err != nil {
7576
return
@@ -87,7 +88,7 @@ func (r *ProjectService) Update(ctx context.Context, params ProjectUpdateParams,
8788
// List projects in an organization, from oldest to newest.
8889
func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *pagination.Page[Project], err error) {
8990
var raw *http.Response
90-
opts = append(r.Options[:], opts...)
91+
opts = slices.Concat(r.Options, opts)
9192
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
9293
path := "v0/projects"
9394
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)

projectbranch.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010
"net/url"
11+
"slices"
1112

1213
"github.com/stainless-api/stainless-api-go/internal/apijson"
1314
"github.com/stainless-api/stainless-api-go/internal/apiquery"
@@ -43,7 +44,7 @@ func NewProjectBranchService(opts ...option.RequestOption) (r ProjectBranchServi
4344
// `branch_from` parameter. In addition, if the revision is a branch name, the
4445
// branch will also inherit custom code changes from that branch.
4546
func (r *ProjectBranchService) New(ctx context.Context, params ProjectBranchNewParams, opts ...option.RequestOption) (res *ProjectBranch, err error) {
46-
opts = append(r.Options[:], opts...)
47+
opts = slices.Concat(r.Options, opts)
4748
precfg, err := requestconfig.PreRequestOptions(opts...)
4849
if err != nil {
4950
return
@@ -60,7 +61,7 @@ func (r *ProjectBranchService) New(ctx context.Context, params ProjectBranchNewP
6061

6162
// Retrieve a project branch by name.
6263
func (r *ProjectBranchService) Get(ctx context.Context, branch string, query ProjectBranchGetParams, opts ...option.RequestOption) (res *ProjectBranch, err error) {
63-
opts = append(r.Options[:], opts...)
64+
opts = slices.Concat(r.Options, opts)
6465
precfg, err := requestconfig.PreRequestOptions(opts...)
6566
if err != nil {
6667
return
@@ -82,7 +83,7 @@ func (r *ProjectBranchService) Get(ctx context.Context, branch string, query Pro
8283
// Retrieve a project branch by name.
8384
func (r *ProjectBranchService) List(ctx context.Context, params ProjectBranchListParams, opts ...option.RequestOption) (res *pagination.Page[ProjectBranchListResponse], err error) {
8485
var raw *http.Response
85-
opts = append(r.Options[:], opts...)
86+
opts = slices.Concat(r.Options, opts)
8687
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
8788
precfg, err := requestconfig.PreRequestOptions(opts...)
8889
if err != nil {
@@ -113,7 +114,7 @@ func (r *ProjectBranchService) ListAutoPaging(ctx context.Context, params Projec
113114

114115
// Delete a project branch by name.
115116
func (r *ProjectBranchService) Delete(ctx context.Context, branch string, body ProjectBranchDeleteParams, opts ...option.RequestOption) (res *ProjectBranchDeleteResponse, err error) {
116-
opts = append(r.Options[:], opts...)
117+
opts = slices.Concat(r.Options, opts)
117118
precfg, err := requestconfig.PreRequestOptions(opts...)
118119
if err != nil {
119120
return
@@ -137,7 +138,7 @@ func (r *ProjectBranchService) Delete(ctx context.Context, branch string, body P
137138
// The branch is rebased onto the `base` branch or commit SHA, inheriting any
138139
// config and custom code changes.
139140
func (r *ProjectBranchService) Rebase(ctx context.Context, branch string, params ProjectBranchRebaseParams, opts ...option.RequestOption) (res *ProjectBranch, err error) {
140-
opts = append(r.Options[:], opts...)
141+
opts = slices.Concat(r.Options, opts)
141142
precfg, err := requestconfig.PreRequestOptions(opts...)
142143
if err != nil {
143144
return

projectconfig.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010
"net/url"
11+
"slices"
1112

1213
"github.com/stainless-api/stainless-api-go/internal/apijson"
1314
"github.com/stainless-api/stainless-api-go/internal/apiquery"
@@ -38,7 +39,7 @@ func NewProjectConfigService(opts ...option.RequestOption) (r ProjectConfigServi
3839

3940
// Retrieve the configuration files for a given project.
4041
func (r *ProjectConfigService) Get(ctx context.Context, params ProjectConfigGetParams, opts ...option.RequestOption) (res *ProjectConfigGetResponse, err error) {
41-
opts = append(r.Options[:], opts...)
42+
opts = slices.Concat(r.Options, opts)
4243
precfg, err := requestconfig.PreRequestOptions(opts...)
4344
if err != nil {
4445
return
@@ -55,7 +56,7 @@ func (r *ProjectConfigService) Get(ctx context.Context, params ProjectConfigGetP
5556

5657
// Generate suggestions for changes to config files based on an OpenAPI spec.
5758
func (r *ProjectConfigService) Guess(ctx context.Context, params ProjectConfigGuessParams, opts ...option.RequestOption) (res *ProjectConfigGuessResponse, err error) {
58-
opts = append(r.Options[:], opts...)
59+
opts = slices.Concat(r.Options, opts)
5960
precfg, err := requestconfig.PreRequestOptions(opts...)
6061
if err != nil {
6162
return

0 commit comments

Comments
 (0)