mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
digitalocean: use a safer pagination method (#7498)
this method is documented here: https://github.com/digitalocean/godo Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
578f2b7974
commit
aa452d8ab4
|
@ -176,7 +176,7 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
|
|||
func (d *Discovery) listDroplets() ([]godo.Droplet, error) {
|
||||
var (
|
||||
droplets []godo.Droplet
|
||||
opts = &godo.ListOptions{Page: 1}
|
||||
opts = &godo.ListOptions{}
|
||||
)
|
||||
for {
|
||||
paginatedDroplets, resp, err := d.client.Droplets.List(context.Background(), opts)
|
||||
|
@ -187,7 +187,13 @@ func (d *Discovery) listDroplets() ([]godo.Droplet, error) {
|
|||
if resp.Links == nil || resp.Links.IsLastPage() {
|
||||
break
|
||||
}
|
||||
opts.Page++
|
||||
|
||||
page, err := resp.Links.CurrentPage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opts.Page = page + 1
|
||||
}
|
||||
return droplets, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue