Skip to content

Commit

Permalink
fix: primary-ip list returns max 50 items (#415)
Browse files Browse the repository at this point in the history
Calls to `primary-ip list` would only return the first page of the results
which by default is 50 items. By using `.AllWithOpts` instead of `.List`,
hcloud-go automatically fetches all pages for us.
  • Loading branch information
apricote authored Nov 11, 2022
1 parent 33fddc3 commit 7d6990f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/primaryip/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var listCmd = base.ListCmd{
if len(sorts) > 0 {
opts.Sort = sorts
}
primaryips, _, err := client.PrimaryIP().List(ctx, opts)
primaryips, err := client.PrimaryIP().AllWithOpts(ctx, opts)

var resources []interface{}
for _, n := range primaryips {
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/primaryip/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestList(t *testing.T) {

fx.ExpectEnsureToken()
fx.Client.PrimaryIPClient.EXPECT().
List(
AllWithOpts(
gomock.Any(),
hcloud.PrimaryIPListOpts{
ListOpts: hcloud.ListOpts{
Expand All @@ -38,7 +38,6 @@ func TestList(t *testing.T) {
IP: net.ParseIP("127.0.0.1"),
},
},
&hcloud.Response{},
nil)

out, err := fx.Run(cmd, []string{"--selector", "foo=bar"})
Expand Down

0 comments on commit 7d6990f

Please sign in to comment.