Skip to content

Commit 083789f

Browse files
fix: use slices.Concat instead of sometimes modifying r.Options
1 parent d1761ab commit 083789f

32 files changed

+152
-120
lines changed

account.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"net/http"
88
"net/url"
9+
"slices"
910
"time"
1011

1112
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
@@ -55,7 +56,7 @@ func NewAccountService(opts ...option.RequestOption) (r *AccountService) {
5556
// {}
5657
// ```
5758
func (r *AccountService) Get(ctx context.Context, body AccountGetParams, opts ...option.RequestOption) (res *AccountGetResponse, err error) {
58-
opts = append(r.Options[:], opts...)
59+
opts = slices.Concat(r.Options, opts)
5960
path := "gitpod.v1.AccountService/GetAccount"
6061
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
6162
return
@@ -81,7 +82,7 @@ func (r *AccountService) Get(ctx context.Context, body AccountGetParams, opts ..
8182
// accountId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
8283
// ```
8384
func (r *AccountService) Delete(ctx context.Context, body AccountDeleteParams, opts ...option.RequestOption) (res *AccountDeleteResponse, err error) {
84-
opts = append(r.Options[:], opts...)
85+
opts = slices.Concat(r.Options, opts)
8586
path := "gitpod.v1.AccountService/DeleteAccount"
8687
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
8788
return
@@ -114,7 +115,7 @@ func (r *AccountService) Delete(ctx context.Context, body AccountDeleteParams, o
114115
// returnTo: "https://gitpod.io/workspaces"
115116
// ```
116117
func (r *AccountService) GetSSOLoginURL(ctx context.Context, body AccountGetSSOLoginURLParams, opts ...option.RequestOption) (res *AccountGetSSOLoginURLResponse, err error) {
117-
opts = append(r.Options[:], opts...)
118+
opts = slices.Concat(r.Options, opts)
118119
path := "gitpod.v1.AccountService/GetSSOLoginURL"
119120
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
120121
return
@@ -138,7 +139,7 @@ func (r *AccountService) GetSSOLoginURL(ctx context.Context, body AccountGetSSOL
138139
// {}
139140
// ```
140141
func (r *AccountService) ListJoinableOrganizations(ctx context.Context, params AccountListJoinableOrganizationsParams, opts ...option.RequestOption) (res *AccountListJoinableOrganizationsResponse, err error) {
141-
opts = append(r.Options[:], opts...)
142+
opts = slices.Concat(r.Options, opts)
142143
path := "gitpod.v1.AccountService/ListJoinableOrganizations"
143144
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
144145
return
@@ -175,7 +176,7 @@ func (r *AccountService) ListJoinableOrganizations(ctx context.Context, params A
175176
// ```
176177
func (r *AccountService) ListLoginProviders(ctx context.Context, params AccountListLoginProvidersParams, opts ...option.RequestOption) (res *pagination.LoginProvidersPage[LoginProvider], err error) {
177178
var raw *http.Response
178-
opts = append(r.Options[:], opts...)
179+
opts = slices.Concat(r.Options, opts)
179180
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
180181
path := "gitpod.v1.AccountService/ListLoginProviders"
181182
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)

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/gitpod-io/gitpod-sdk-go/internal/requestconfig"
1112
"github.com/gitpod-io/gitpod-sdk-go/option"
@@ -102,7 +103,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
102103
// For even greater flexibility, see [option.WithResponseInto] and
103104
// [option.WithResponseBodyInto].
104105
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error {
105-
opts = append(r.Options, opts...)
106+
opts = slices.Concat(r.Options, opts)
106107
return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)
107108
}
108109

editor.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"net/http"
88
"net/url"
9+
"slices"
910

1011
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
1112
"github.com/gitpod-io/gitpod-sdk-go/internal/apiquery"
@@ -51,7 +52,7 @@ func NewEditorService(opts ...option.RequestOption) (r *EditorService) {
5152
// id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
5253
// ```
5354
func (r *EditorService) Get(ctx context.Context, body EditorGetParams, opts ...option.RequestOption) (res *EditorGetResponse, err error) {
54-
opts = append(r.Options[:], opts...)
55+
opts = slices.Concat(r.Options, opts)
5556
path := "gitpod.v1.EditorService/GetEditor"
5657
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
5758
return
@@ -91,7 +92,7 @@ func (r *EditorService) Get(ctx context.Context, body EditorGetParams, opts ...o
9192
// ```
9293
func (r *EditorService) List(ctx context.Context, params EditorListParams, opts ...option.RequestOption) (res *pagination.EditorsPage[Editor], err error) {
9394
var raw *http.Response
94-
opts = append(r.Options[:], opts...)
95+
opts = slices.Concat(r.Options, opts)
9596
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
9697
path := "gitpod.v1.EditorService/ListEditors"
9798
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
@@ -163,7 +164,7 @@ func (r *EditorService) ListAutoPaging(ctx context.Context, params EditorListPar
163164
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
164165
// ```
165166
func (r *EditorService) ResolveURL(ctx context.Context, body EditorResolveURLParams, opts ...option.RequestOption) (res *EditorResolveURLResponse, err error) {
166-
opts = append(r.Options[:], opts...)
167+
opts = slices.Concat(r.Options, opts)
167168
path := "gitpod.v1.EditorService/ResolveEditorURL"
168169
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
169170
return

environment.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"net/http"
88
"net/url"
9+
"slices"
910
"time"
1011

1112
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
@@ -102,7 +103,7 @@ func NewEnvironmentService(opts ...option.RequestOption) (r *EnvironmentService)
102103
// name: "Web App"
103104
// ```
104105
func (r *EnvironmentService) New(ctx context.Context, body EnvironmentNewParams, opts ...option.RequestOption) (res *EnvironmentNewResponse, err error) {
105-
opts = append(r.Options[:], opts...)
106+
opts = slices.Concat(r.Options, opts)
106107
path := "gitpod.v1.EnvironmentService/CreateEnvironment"
107108
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
108109
return
@@ -129,7 +130,7 @@ func (r *EnvironmentService) New(ctx context.Context, body EnvironmentNewParams,
129130
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
130131
// ```
131132
func (r *EnvironmentService) Get(ctx context.Context, body EnvironmentGetParams, opts ...option.RequestOption) (res *EnvironmentGetResponse, err error) {
132-
opts = append(r.Options[:], opts...)
133+
opts = slices.Concat(r.Options, opts)
133134
path := "gitpod.v1.EnvironmentService/GetEnvironment"
134135
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
135136
return
@@ -186,7 +187,7 @@ func (r *EnvironmentService) Get(ctx context.Context, body EnvironmentGetParams,
186187
// Note: Machine class changes require stopping the environment and creating a new
187188
// one.
188189
func (r *EnvironmentService) Update(ctx context.Context, body EnvironmentUpdateParams, opts ...option.RequestOption) (res *EnvironmentUpdateResponse, err error) {
189-
opts = append(r.Options[:], opts...)
190+
opts = slices.Concat(r.Options, opts)
190191
path := "gitpod.v1.EnvironmentService/UpdateEnvironment"
191192
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
192193
return
@@ -231,7 +232,7 @@ func (r *EnvironmentService) Update(ctx context.Context, body EnvironmentUpdateP
231232
// ```
232233
func (r *EnvironmentService) List(ctx context.Context, params EnvironmentListParams, opts ...option.RequestOption) (res *pagination.EnvironmentsPage[Environment], err error) {
233234
var raw *http.Response
234-
opts = append(r.Options[:], opts...)
235+
opts = slices.Concat(r.Options, opts)
235236
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
236237
path := "gitpod.v1.EnvironmentService/ListEnvironments"
237238
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
@@ -312,7 +313,7 @@ func (r *EnvironmentService) ListAutoPaging(ctx context.Context, params Environm
312313
// force: true
313314
// ```
314315
func (r *EnvironmentService) Delete(ctx context.Context, body EnvironmentDeleteParams, opts ...option.RequestOption) (res *EnvironmentDeleteResponse, err error) {
315-
opts = append(r.Options[:], opts...)
316+
opts = slices.Concat(r.Options, opts)
316317
path := "gitpod.v1.EnvironmentService/DeleteEnvironment"
317318
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
318319
return
@@ -333,7 +334,7 @@ func (r *EnvironmentService) Delete(ctx context.Context, body EnvironmentDeleteP
333334
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
334335
// ```
335336
func (r *EnvironmentService) NewEnvironmentToken(ctx context.Context, body EnvironmentNewEnvironmentTokenParams, opts ...option.RequestOption) (res *EnvironmentNewEnvironmentTokenResponse, err error) {
336-
opts = append(r.Options[:], opts...)
337+
opts = slices.Concat(r.Options, opts)
337338
path := "gitpod.v1.EnvironmentService/CreateEnvironmentAccessToken"
338339
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
339340
return
@@ -370,7 +371,7 @@ func (r *EnvironmentService) NewEnvironmentToken(ctx context.Context, body Envir
370371
// disconnected: "14400s" # 4 hours in seconds
371372
// ```
372373
func (r *EnvironmentService) NewFromProject(ctx context.Context, body EnvironmentNewFromProjectParams, opts ...option.RequestOption) (res *EnvironmentNewFromProjectResponse, err error) {
373-
opts = append(r.Options[:], opts...)
374+
opts = slices.Concat(r.Options, opts)
374375
path := "gitpod.v1.EnvironmentService/CreateEnvironmentFromProject"
375376
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
376377
return
@@ -391,7 +392,7 @@ func (r *EnvironmentService) NewFromProject(ctx context.Context, body Environmen
391392
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
392393
// ```
393394
func (r *EnvironmentService) NewLogsToken(ctx context.Context, body EnvironmentNewLogsTokenParams, opts ...option.RequestOption) (res *EnvironmentNewLogsTokenResponse, err error) {
394-
opts = append(r.Options[:], opts...)
395+
opts = slices.Concat(r.Options, opts)
395396
path := "gitpod.v1.EnvironmentService/CreateEnvironmentLogsToken"
396397
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
397398
return
@@ -415,7 +416,7 @@ func (r *EnvironmentService) NewLogsToken(ctx context.Context, body EnvironmentN
415416
// timestamp: "2025-02-12T14:30:00Z"
416417
// ```
417418
func (r *EnvironmentService) MarkActive(ctx context.Context, body EnvironmentMarkActiveParams, opts ...option.RequestOption) (res *EnvironmentMarkActiveResponse, err error) {
418-
opts = append(r.Options[:], opts...)
419+
opts = slices.Concat(r.Options, opts)
419420
path := "gitpod.v1.EnvironmentService/MarkEnvironmentActive"
420421
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
421422
return
@@ -437,7 +438,7 @@ func (r *EnvironmentService) MarkActive(ctx context.Context, body EnvironmentMar
437438
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
438439
// ```
439440
func (r *EnvironmentService) Start(ctx context.Context, body EnvironmentStartParams, opts ...option.RequestOption) (res *EnvironmentStartResponse, err error) {
440-
opts = append(r.Options[:], opts...)
441+
opts = slices.Concat(r.Options, opts)
441442
path := "gitpod.v1.EnvironmentService/StartEnvironment"
442443
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
443444
return
@@ -458,7 +459,7 @@ func (r *EnvironmentService) Start(ctx context.Context, body EnvironmentStartPar
458459
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
459460
// ```
460461
func (r *EnvironmentService) Stop(ctx context.Context, body EnvironmentStopParams, opts ...option.RequestOption) (res *EnvironmentStopResponse, err error) {
461-
opts = append(r.Options[:], opts...)
462+
opts = slices.Concat(r.Options, opts)
462463
path := "gitpod.v1.EnvironmentService/StopEnvironment"
463464
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
464465
return
@@ -474,7 +475,7 @@ func (r *EnvironmentService) Stop(ctx context.Context, body EnvironmentStopParam
474475
// environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
475476
// ```
476477
func (r *EnvironmentService) Unarchive(ctx context.Context, body EnvironmentUnarchiveParams, opts ...option.RequestOption) (res *EnvironmentUnarchiveResponse, err error) {
477-
opts = append(r.Options[:], opts...)
478+
opts = slices.Concat(r.Options, opts)
478479
path := "gitpod.v1.EnvironmentService/UnarchiveEnvironment"
479480
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
480481
return

environmentautomation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package gitpod
55
import (
66
"context"
77
"net/http"
8+
"slices"
89

910
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
1011
"github.com/gitpod-io/gitpod-sdk-go/internal/param"
@@ -71,7 +72,7 @@ func NewEnvironmentAutomationService(opts ...option.RequestOption) (r *Environme
7172
// - postEnvironmentStart
7273
// ```
7374
func (r *EnvironmentAutomationService) Upsert(ctx context.Context, body EnvironmentAutomationUpsertParams, opts ...option.RequestOption) (res *EnvironmentAutomationUpsertResponse, err error) {
74-
opts = append(r.Options[:], opts...)
75+
opts = slices.Concat(r.Options, opts)
7576
path := "gitpod.v1.EnvironmentAutomationService/UpsertAutomationsFile"
7677
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
7778
return

environmentautomationservice.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"net/http"
88
"net/url"
9+
"slices"
910
"time"
1011

1112
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
@@ -83,7 +84,7 @@ func NewEnvironmentAutomationServiceService(opts ...option.RequestOption) (r *En
8384
// image: "redis:7"
8485
// ```
8586
func (r *EnvironmentAutomationServiceService) New(ctx context.Context, body EnvironmentAutomationServiceNewParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceNewResponse, err error) {
86-
opts = append(r.Options[:], opts...)
87+
opts = slices.Concat(r.Options, opts)
8788
path := "gitpod.v1.EnvironmentAutomationService/CreateService"
8889
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
8990
return
@@ -108,7 +109,7 @@ func (r *EnvironmentAutomationServiceService) New(ctx context.Context, body Envi
108109
// id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
109110
// ```
110111
func (r *EnvironmentAutomationServiceService) Get(ctx context.Context, body EnvironmentAutomationServiceGetParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceGetResponse, err error) {
111-
opts = append(r.Options[:], opts...)
112+
opts = slices.Concat(r.Options, opts)
112113
path := "gitpod.v1.EnvironmentAutomationService/GetService"
113114
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
114115
return
@@ -150,7 +151,7 @@ func (r *EnvironmentAutomationServiceService) Get(ctx context.Context, body Envi
150151
// - manual: true
151152
// ```
152153
func (r *EnvironmentAutomationServiceService) Update(ctx context.Context, body EnvironmentAutomationServiceUpdateParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceUpdateResponse, err error) {
153-
opts = append(r.Options[:], opts...)
154+
opts = slices.Concat(r.Options, opts)
154155
path := "gitpod.v1.EnvironmentAutomationService/UpdateService"
155156
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
156157
return
@@ -189,7 +190,7 @@ func (r *EnvironmentAutomationServiceService) Update(ctx context.Context, body E
189190
// ```
190191
func (r *EnvironmentAutomationServiceService) List(ctx context.Context, params EnvironmentAutomationServiceListParams, opts ...option.RequestOption) (res *pagination.ServicesPage[Service], err error) {
191192
var raw *http.Response
192-
opts = append(r.Options[:], opts...)
193+
opts = slices.Concat(r.Options, opts)
193194
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
194195
path := "gitpod.v1.EnvironmentAutomationService/ListServices"
195196
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &res, opts...)
@@ -268,7 +269,7 @@ func (r *EnvironmentAutomationServiceService) ListAutoPaging(ctx context.Context
268269
// force: true
269270
// ```
270271
func (r *EnvironmentAutomationServiceService) Delete(ctx context.Context, body EnvironmentAutomationServiceDeleteParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceDeleteResponse, err error) {
271-
opts = append(r.Options[:], opts...)
272+
opts = slices.Concat(r.Options, opts)
272273
path := "gitpod.v1.EnvironmentAutomationService/DeleteService"
273274
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
274275
return
@@ -294,7 +295,7 @@ func (r *EnvironmentAutomationServiceService) Delete(ctx context.Context, body E
294295
// id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
295296
// ```
296297
func (r *EnvironmentAutomationServiceService) Start(ctx context.Context, body EnvironmentAutomationServiceStartParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceStartResponse, err error) {
297-
opts = append(r.Options[:], opts...)
298+
opts = slices.Concat(r.Options, opts)
298299
path := "gitpod.v1.EnvironmentAutomationService/StartService"
299300
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
300301
return
@@ -320,7 +321,7 @@ func (r *EnvironmentAutomationServiceService) Start(ctx context.Context, body En
320321
// id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
321322
// ```
322323
func (r *EnvironmentAutomationServiceService) Stop(ctx context.Context, body EnvironmentAutomationServiceStopParams, opts ...option.RequestOption) (res *EnvironmentAutomationServiceStopResponse, err error) {
323-
opts = append(r.Options[:], opts...)
324+
opts = slices.Concat(r.Options, opts)
324325
path := "gitpod.v1.EnvironmentAutomationService/StopService"
325326
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
326327
return

0 commit comments

Comments
 (0)