Skip to content

Commit ec404a4

Browse files
committed
fix(privatenetworks): PrivateNetworksDomainsList must take a pagination.Request in argument
1 parent cf71055 commit ec404a4

File tree

12 files changed

+32
-67
lines changed

12 files changed

+32
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* feat(run): add a `bash` alias for us out there often forgetting the `run` in front
1010
* feat(sshkeys): add support for ed25519 keys
1111
* feat(apps/create): detect Git main branch name
12+
* fix(privatenetworks): `PrivateNetworksDomainsList` must take a `pagination.Request` in argument
1213

1314
## 1.43.3
1415

cmd/deployments.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ var (
5454
`,
5555
Action: func(ctx context.Context, c *cli.Command) error {
5656
currentApp := detect.CurrentApp(ctx, c)
57-
err := deployments.List(ctx, currentApp, pagination.Request{
58-
Page: c.Int("page"),
59-
PerPage: c.Int("per-page"),
60-
})
57+
err := deployments.List(ctx, currentApp, pagination.NewRequest(c.Int("page"), c.Int("per-page")))
6158
if err != nil {
6259
errorQuit(ctx, err)
6360
}

cmd/maintenance.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ var databaseMaintenanceList = cli.Command{
3838
addonName = addonUUIDFromFlags(ctx, c, currentResource, true)
3939
}
4040

41-
err := maintenance.List(ctx, currentResource, addonName, pagination.Request{
42-
Page: c.Int("page"),
43-
PerPage: c.Int("per-page"),
44-
})
41+
err := maintenance.List(ctx, currentResource, addonName, pagination.NewRequest(c.Int("page"), c.Int("per-page")))
4542
if err != nil {
4643
errorQuit(ctx, err)
4744
}

cmd/privatenetworks.go

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ package cmd
22

33
import (
44
"context"
5-
"strconv"
65

76
"github.com/sirupsen/logrus"
87
"github.com/urfave/cli/v3"
98

109
"github.com/Scalingo/cli/cmd/autocomplete"
1110
"github.com/Scalingo/cli/detect"
1211
"github.com/Scalingo/cli/privatenetworks"
13-
"github.com/Scalingo/go-utils/errors/v3"
1412
"github.com/Scalingo/go-utils/logger"
13+
"github.com/Scalingo/go-utils/pagination"
1514
)
1615

1716
const (
@@ -29,14 +28,14 @@ var (
2928
Value: outputFormatTable,
3029
Usage: "[" + outputFormatJSON + "|" + outputFormatTable + "]",
3130
},
32-
&cli.StringFlag{
31+
&cli.IntFlag{
3332
Name: "page",
34-
Value: "1",
33+
Value: 1,
3534
Usage: "[page]",
3635
},
37-
&cli.StringFlag{
36+
&cli.IntFlag{
3837
Name: "per-page",
39-
Value: "20",
38+
Value: 20,
4039
Usage: "[per-page]",
4140
},
4241
},
@@ -55,35 +54,18 @@ var (
5554
return nil
5655
}
5756

58-
pageStr := c.String("page")
59-
perPageStr := c.String("per-page")
57+
page := c.Int("page")
58+
perPage := c.Int("per-page")
6059
formatStr := c.String("format")
6160
ctx, _ = logger.WithFieldsToCtx(ctx, logrus.Fields{
62-
"page": pageStr,
63-
"per_page": perPageStr,
61+
"page": page,
62+
"per_page": perPage,
6463
"format": formatStr,
6564
})
6665

67-
var err error
68-
var page int
69-
if pageStr != "" {
70-
page, err = strconv.Atoi(pageStr)
71-
if err != nil || page < 1 {
72-
return errors.New(ctx, "invalid page number")
73-
}
74-
}
75-
76-
var perPage int
77-
if perPageStr != "" {
78-
perPage, err = strconv.Atoi(perPageStr)
79-
if err != nil || perPage < 1 || perPage > 50 {
80-
return errors.New(ctx, "invalid per_page number")
81-
}
82-
}
83-
8466
currentApp := detect.CurrentApp(ctx, c)
8567

86-
err = privatenetworks.List(ctx, currentApp, formatStr, uint(page), uint(perPage))
68+
err := privatenetworks.List(ctx, currentApp, formatStr, pagination.NewRequest(page, perPage))
8769
if err != nil {
8870
errorQuit(ctx, err)
8971
}

cmd/timeline.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ var (
3636
}
3737

3838
utils.CheckForConsent(ctx, currentResource)
39-
err := apps.Events(ctx, currentResource, pagination.Request{
40-
Page: c.Int("page"),
41-
PerPage: c.Int("per-page"),
42-
})
39+
err := apps.Events(ctx, currentResource, pagination.NewRequest(c.Int("page"), c.Int("per-page")))
4340
if err != nil {
4441
errorQuit(ctx, err)
4542
}

cmd/user-timeline.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ var (
2727
Action: func(ctx context.Context, c *cli.Command) error {
2828
var err error
2929
if c.Args().Len() == 0 {
30-
err = user.Events(ctx, pagination.Request{
31-
Page: c.Int("page"),
32-
PerPage: c.Int("per-page"),
33-
})
30+
err = user.Events(ctx, pagination.NewRequest(c.Int("page"), c.Int("per-page")))
3431
} else {
3532
_ = cli.ShowCommandHelp(ctx, c, "user-timeline")
3633
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.0
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.7
7-
github.com/Scalingo/go-scalingo/v10 v10.0.0
7+
github.com/Scalingo/go-scalingo/v10 v10.0.1-0.20260311102844-5accba791cec
88
github.com/Scalingo/go-utils/errors/v3 v3.2.0
99
github.com/Scalingo/go-utils/logger v1.12.0
1010
github.com/Scalingo/go-utils/pagination v1.2.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n
99
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
1010
github.com/ProtonMail/go-crypto v1.4.0 h1:Zq/pbM3F5DFgJiMouxEdSVY44MVoQNEKp5d5QxIQceQ=
1111
github.com/ProtonMail/go-crypto v1.4.0/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
12-
github.com/Scalingo/go-scalingo/v10 v10.0.0 h1:xUbb+MTkzdgWisXhw3MHa0nVSVuossNZJBjw8ak1AFc=
13-
github.com/Scalingo/go-scalingo/v10 v10.0.0/go.mod h1:d5J8wm6cO1bEycKuLXuWfGY99OhmYR3ATu7QRYvAEAk=
12+
github.com/Scalingo/go-scalingo/v10 v10.0.1-0.20260311102844-5accba791cec h1:h4l4cms9OlSHVGbeuqWDw0cVAfS1LDiDn5E+3z6Zty4=
13+
github.com/Scalingo/go-scalingo/v10 v10.0.1-0.20260311102844-5accba791cec/go.mod h1:d5J8wm6cO1bEycKuLXuWfGY99OhmYR3ATu7QRYvAEAk=
1414
github.com/Scalingo/go-utils/errors/v3 v3.2.0 h1:Ks+v2oRwv3VZfe+xVB+kpfmZouXHVCPHHtwL5W60prc=
1515
github.com/Scalingo/go-utils/errors/v3 v3.2.0/go.mod h1:jVVNoOdYFjuNkR/BeEZWNWJVvu4jmyLY4udlsQQyBss=
1616
github.com/Scalingo/go-utils/logger v1.12.0 h1:tK1LwRz7ijYLGe7/c4SzAtNEJCbSPQnOo859O1FsOLM=

privatenetworks/list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ import (
1212

1313
"github.com/Scalingo/cli/config"
1414
"github.com/Scalingo/go-utils/errors/v3"
15+
"github.com/Scalingo/go-utils/pagination"
1516
)
1617

1718
const containerTypeWeb = "web"
1819

19-
func List(ctx context.Context, app string, format string, page uint, perPage uint) error {
20+
func List(ctx context.Context, app string, format string, paginationReq pagination.Request) error {
2021
scalingoClient, err := config.ScalingoClient(ctx)
2122
if err != nil {
2223
return errors.Wrapf(ctx, err, "get Scalingo client")
2324
}
2425

25-
domainNames, err := scalingoClient.PrivateNetworksDomainsList(ctx, app, page, perPage)
26+
domainNames, err := scalingoClient.PrivateNetworksDomainsList(ctx, app, paginationReq)
2627
if err != nil {
2728
return errors.Wrapf(ctx, err, "list private network domains")
2829
}

vendor/github.com/Scalingo/go-scalingo/v10/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)