From ad45e49bd2f0b43e5b46c932a29a5f3fb8a333c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Wed, 9 Nov 2022 18:26:58 +0100 Subject: [PATCH] PrimaryIPClient Add AllWithOpts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was missed when implementing the primary ip client. Signed-off-by: Lukas Kämmerling --- hcloud/primary_ip.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hcloud/primary_ip.go b/hcloud/primary_ip.go index c534c89a..a41729ea 100644 --- a/hcloud/primary_ip.go +++ b/hcloud/primary_ip.go @@ -240,10 +240,12 @@ func (c *PrimaryIPClient) List(ctx context.Context, opts PrimaryIPListOpts) ([]* // All returns all Primary IPs. func (c *PrimaryIPClient) All(ctx context.Context) ([]*PrimaryIP, error) { - allPrimaryIPs := []*PrimaryIP{} + return c.AllWithOpts(ctx, PrimaryIPListOpts{ListOpts: ListOpts{PerPage: 50}}) +} - opts := PrimaryIPListOpts{} - opts.PerPage = 50 +// AllWithOpts returns all Primary IPs for the given options. +func (c *PrimaryIPClient) AllWithOpts(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, error) { + var allPrimaryIPs []*PrimaryIP err := c.client.all(func(page int) (*Response, error) { opts.Page = page @@ -251,7 +253,7 @@ func (c *PrimaryIPClient) All(ctx context.Context) ([]*PrimaryIP, error) { if err != nil { return resp, err } - allPrimaryIPs = append(allPrimaryIPs, primaryIPs...) + primaryIPs = append(allPrimaryIPs, primaryIPs...) return resp, nil }) if err != nil {