Skip to content

Commit 5905d56

Browse files
authored
Merge pull request #482 from Scalingo/refactor/go_fix
refactor: autofix by `go fix`
2 parents 7b347f1 + 8ee244b commit 5905d56

31 files changed

+165
-168
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* build(deps): update `github.com/golang-jwt/jwt` from v4 to v5
77
* refactor: replace `errgo` with `github.com/Scalingo/go-utils/errors/v3` (breaking change)
88
* feat(logs): `LogsURL` returns a parsed structure (breaking change)
9+
* refactor: autofix by `go fix`
910

1011
## 9.2.0
1112

addons_providers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestAddonProvidersClient(t *testing.T) {
2020
expectedEndpoint string
2121
expectedMethod string
2222
expectedQuery string
23-
response interface{}
23+
response any
2424
responseStatus int
2525
noBody bool
2626
}{

alerts.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ type AlertsService interface {
1818
var _ AlertsService = (*Client)(nil)
1919

2020
type Alert struct {
21-
ID string `json:"id"`
22-
AppID string `json:"app_id"`
23-
ContainerType string `json:"container_type"`
24-
Metric string `json:"metric"`
25-
Limit float64 `json:"limit"`
26-
Disabled bool `json:"disabled"`
27-
SendWhenBelow bool `json:"send_when_below"`
28-
DurationBeforeTrigger time.Duration `json:"duration_before_trigger"`
29-
RemindEvery string `json:"remind_every"`
30-
CreatedAt time.Time `json:"created_at"`
31-
UpdatedAt time.Time `json:"updated_at"`
32-
Metadata map[string]interface{} `json:"metadata"`
33-
Notifiers []string `json:"notifiers"`
21+
ID string `json:"id"`
22+
AppID string `json:"app_id"`
23+
ContainerType string `json:"container_type"`
24+
Metric string `json:"metric"`
25+
Limit float64 `json:"limit"`
26+
Disabled bool `json:"disabled"`
27+
SendWhenBelow bool `json:"send_when_below"`
28+
DurationBeforeTrigger time.Duration `json:"duration_before_trigger"`
29+
RemindEvery string `json:"remind_every"`
30+
CreatedAt time.Time `json:"created_at"`
31+
UpdatedAt time.Time `json:"updated_at"`
32+
Metadata map[string]any `json:"metadata"`
33+
Notifiers []string `json:"notifiers"`
3434
}
3535

3636
type AlertsRes struct {

alerts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAlertsClient(t *testing.T) {
2222
testedClientCall func(c AlertsService) error
2323
expectedEndpoint string
2424
expectedMethod string
25-
response interface{}
25+
response any
2626
responseStatus int
2727
noBody bool
2828
}{

apps.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,29 @@ type AppLinks struct {
9696
}
9797

9898
type App struct {
99-
ID string `json:"id"`
100-
Name string `json:"name"`
101-
Region string `json:"region"`
102-
Owner Owner `json:"owner"`
103-
GitURL string `json:"git_url"`
104-
URL string `json:"url"`
105-
BaseURL string `json:"base_url"`
106-
Status AppStatus `json:"status"`
107-
LastDeployedAt *time.Time `json:"last_deployed_at"`
108-
LastDeployedBy string `json:"last_deployed_by"`
109-
CreatedAt *time.Time `json:"created_at"`
110-
UpdatedAt *time.Time `json:"updated_at"`
111-
Links *AppLinks `json:"links"`
112-
StackID string `json:"stack_id"`
113-
StickySession bool `json:"sticky_session"`
114-
ForceHTTPS bool `json:"force_https"`
115-
RouterLogs bool `json:"router_logs"`
116-
DataAccessConsent *DataAccessConsent `json:"data_access_consent,omitempty"`
117-
Flags map[string]bool `json:"flags"`
118-
Limits map[string]interface{} `json:"limits"`
119-
HDSResource bool `json:"hds_resource"`
120-
PrivateNetworksIDs []string `json:"private_networks_ids"`
121-
Project appProject `json:"project,omitempty"`
99+
ID string `json:"id"`
100+
Name string `json:"name"`
101+
Region string `json:"region"`
102+
Owner Owner `json:"owner"`
103+
GitURL string `json:"git_url"`
104+
URL string `json:"url"`
105+
BaseURL string `json:"base_url"`
106+
Status AppStatus `json:"status"`
107+
LastDeployedAt *time.Time `json:"last_deployed_at"`
108+
LastDeployedBy string `json:"last_deployed_by"`
109+
CreatedAt *time.Time `json:"created_at"`
110+
UpdatedAt *time.Time `json:"updated_at"`
111+
Links *AppLinks `json:"links"`
112+
StackID string `json:"stack_id"`
113+
StickySession bool `json:"sticky_session"`
114+
ForceHTTPS bool `json:"force_https"`
115+
RouterLogs bool `json:"router_logs"`
116+
DataAccessConsent *DataAccessConsent `json:"data_access_consent,omitempty"`
117+
Flags map[string]bool `json:"flags"`
118+
Limits map[string]any `json:"limits"`
119+
HDSResource bool `json:"hds_resource"`
120+
PrivateNetworksIDs []string `json:"private_networks_ids"`
121+
Project appProject `json:"project"`
122122
}
123123

124124
// appProject is a partial copy of the type `Project` in `projects.go`
@@ -169,7 +169,7 @@ func (c *Client) AppsDestroy(ctx context.Context, name string, currentName strin
169169
Method: "DELETE",
170170
Endpoint: "/apps/" + name,
171171
Expected: httpclient.Statuses{204},
172-
Params: map[string]interface{}{
172+
Params: map[string]any{
173173
"current_name": currentName,
174174
},
175175
}
@@ -187,7 +187,7 @@ func (c *Client) AppsRename(ctx context.Context, name string, newName string) (*
187187
Method: "POST",
188188
Endpoint: "/apps/" + name + "/rename",
189189
Expected: httpclient.Statuses{200},
190-
Params: map[string]interface{}{
190+
Params: map[string]any{
191191
"current_name": name,
192192
"new_name": newName,
193193
},
@@ -206,7 +206,7 @@ func (c *Client) AppsTransfer(ctx context.Context, name string, email string) (*
206206
Method: "PATCH",
207207
Endpoint: "/apps/" + name,
208208
Expected: httpclient.Statuses{200},
209-
Params: map[string]interface{}{
209+
Params: map[string]any{
210210
"app": map[string]string{
211211
"owner": email,
212212
},
@@ -225,7 +225,7 @@ func (c *Client) AppsSetStack(ctx context.Context, app string, stackID string) (
225225
Method: "PATCH",
226226
Endpoint: "/apps/" + app,
227227
Expected: httpclient.Statuses{200},
228-
Params: map[string]interface{}{
228+
Params: map[string]any{
229229
"app": map[string]string{
230230
"stack_id": stackID,
231231
},
@@ -258,7 +258,7 @@ func (c *Client) AppsCreate(ctx context.Context, opts AppsCreateOpts) (*App, err
258258
Method: "POST",
259259
Endpoint: "/apps",
260260
Expected: httpclient.Statuses{201},
261-
Params: map[string]interface{}{"app": opts},
261+
Params: map[string]any{"app": opts},
262262
}
263263
err := c.ScalingoAPI().DoRequest(ctx, req, &appRes)
264264
if err != nil {
@@ -318,30 +318,30 @@ func (c *Client) AppsScale(ctx context.Context, app string, params *AppsScalePar
318318
}
319319

320320
func (c *Client) AppsForceHTTPS(ctx context.Context, name string, enable bool) (*App, error) {
321-
return c.appsUpdate(ctx, name, map[string]interface{}{
321+
return c.appsUpdate(ctx, name, map[string]any{
322322
"force_https": enable,
323323
})
324324
}
325325

326326
func (c *Client) AppsRouterLogs(ctx context.Context, name string, enable bool) (*App, error) {
327-
return c.appsUpdate(ctx, name, map[string]interface{}{
327+
return c.appsUpdate(ctx, name, map[string]any{
328328
"router_logs": enable,
329329
})
330330
}
331331

332332
func (c *Client) AppsStickySession(ctx context.Context, name string, enable bool) (*App, error) {
333-
return c.appsUpdate(ctx, name, map[string]interface{}{
333+
return c.appsUpdate(ctx, name, map[string]any{
334334
"sticky_session": enable,
335335
})
336336
}
337337

338338
func (c *Client) AppsSetProject(ctx context.Context, name string, projectID string) (*App, error) {
339-
return c.appsUpdate(ctx, name, map[string]interface{}{
339+
return c.appsUpdate(ctx, name, map[string]any{
340340
"project_id": projectID,
341341
})
342342
}
343343

344-
func (c *Client) appsUpdate(ctx context.Context, name string, params map[string]interface{}) (*App, error) {
344+
func (c *Client) appsUpdate(ctx context.Context, name string, params map[string]any) (*App, error) {
345345
var appRes *AppResponse
346346
req := &httpclient.APIRequest{
347347
Method: "PUT",

apps_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAppsClient_Update(t *testing.T) {
2222
expectedEndpoint string
2323
expectedMethod string
2424
expectedParams string
25-
response interface{}
25+
response any
2626
responseStatus int
2727
}{
2828
"it should enable the app router_logs attribute": {

auth_mock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func MockAuth(ctrl *gomock.Controller) *httpmock.MockClient {
2929
}
3030

3131
return &http.Response{
32-
Body: io.NopCloser(bytes.NewBuffer([]byte(fmt.Sprintf(`{"token": "%v"}`, jwt)))),
32+
Body: io.NopCloser(bytes.NewBuffer(fmt.Appendf(nil, `{"token": "%v"}`, jwt))),
3333
}, nil
3434
}).AnyTimes()
3535
return mock

client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestNewClient(t *testing.T) {
5454
require.True(t, ok)
5555
assert.Equal(t, "api-token", password)
5656
w.WriteHeader(200)
57-
_, err := w.Write([]byte(fmt.Sprintf(`{"token": "%v"}`, jwt)))
57+
_, err := w.Write(fmt.Appendf(nil, `{"token": "%v"}`, jwt))
5858
assert.NoError(t, err)
5959
}
6060
if strings.Contains(r.URL.Path, "self") {

container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (c *Client) ContainersKill(ctx context.Context, app string, signal string,
4747
req := &httpclient.APIRequest{
4848
Method: "POST",
4949
Endpoint: "/apps/" + app + "/containers/" + containerID + "/kill",
50-
Params: map[string]interface{}{"signal": signal},
50+
Params: map[string]any{"signal": signal},
5151
Expected: httpclient.Statuses{204},
5252
}
5353
err := c.ScalingoAPI().DoRequest(ctx, req, nil)

cron_tasks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ var _ CronTasksService = (*Client)(nil)
1616
type Job struct {
1717
Command string `json:"command"`
1818
Size string `json:"size,omitempty"`
19-
LastExecutionDate time.Time `json:"last_execution_date,omitempty"`
20-
NextExecutionDate time.Time `json:"next_execution_date,omitempty"`
19+
LastExecutionDate time.Time `json:"last_execution_date"`
20+
NextExecutionDate time.Time `json:"next_execution_date"`
2121
}
2222

2323
type CronTasks struct {

0 commit comments

Comments
 (0)