From 37c6ef96610ea1a3308e687c48c313f23e6c350e Mon Sep 17 00:00:00 2001 From: johncming Date: Fri, 11 Feb 2022 16:23:51 +0800 Subject: [PATCH] discovery/digitalocean: make do api be aware of discovery context. (#10281) Signed-off-by: johncming --- discovery/digitalocean/digitalocean.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/discovery/digitalocean/digitalocean.go b/discovery/digitalocean/digitalocean.go index 10f8582eb..e207388b3 100644 --- a/discovery/digitalocean/digitalocean.go +++ b/discovery/digitalocean/digitalocean.go @@ -138,7 +138,7 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { Source: "DigitalOcean", } - droplets, err := d.listDroplets() + droplets, err := d.listDroplets(ctx) if err != nil { return nil, err } @@ -196,13 +196,13 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { return []*targetgroup.Group{tg}, nil } -func (d *Discovery) listDroplets() ([]godo.Droplet, error) { +func (d *Discovery) listDroplets(ctx context.Context) ([]godo.Droplet, error) { var ( droplets []godo.Droplet opts = &godo.ListOptions{} ) for { - paginatedDroplets, resp, err := d.client.Droplets.List(context.Background(), opts) + paginatedDroplets, resp, err := d.client.Droplets.List(ctx, opts) if err != nil { return nil, fmt.Errorf("error while listing droplets page %d: %w", opts.Page, err) }