Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone: allow ListZonesContext to automatically handle pagination #534

Merged

Conversation

jacobbednarz
Copy link
Member

Updates the ListZonesContext method to automatically handle the
pagination provided by the API response to return all zones regardless
of the number of entries.

This will fix cloudflare/terraform-provider-cloudflare#790 which uses
this functionality for filtering the data resource.

Fixes cloudflare/terraform-provider-cloudflare#790

Updates the `ListZonesContext` method to automatically handle the
pagination provided by the API response to return all zones regardless
of the number of entries.

This will fix cloudflare/terraform-provider-cloudflare#790 which uses
this functionality for filtering the data resource.

Fixes cloudflare/terraform-provider-cloudflare#790
@jacobbednarz
Copy link
Member Author

Confirmed the functionality is working however the tests aren't happy with it. I'll dig into the tests and find out why.

The functionality within the `ListZonesContext` uses the `TotalPages`
value to determine how many times it needs to enumerate the zones.
Without this, it doesn't at all and results in no zones being found.
@jacobbednarz
Copy link
Member Author

I've updated the stubbed response in 259a650 which was the cause of the failing test 🤦‍♂️

totalPageCount := r.TotalPages
var wg sync.WaitGroup
wg.Add(totalPageCount)
errc := make(chan error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem we handle errors returned from channel in any way. We should return them at the end of the function, even a single one is enough. We might also want to cancel pending requests if any goroutine fails this way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you mean? Or did you have something else in mind for the error being returned? I'm not explicitly cancelling the routine but can drop it in if the channel error reporting isn't enough here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circling back on this one @patryk as we've still got an issue open in the Terraform provider depending on this one.

@jacobbednarz
Copy link
Member Author

As this is holding up a Terraform fix (and has sat for a while), let's merge this one in and when we want to fix the error handling you're mentioning we can raise a separate PR to address.

@jacobbednarz jacobbednarz merged commit 8ce0dc7 into cloudflare:master Jan 17, 2021
@jacobbednarz jacobbednarz deleted the allow-list-zones-cxt-to-paginate branch January 17, 2021 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

data.cloudflare_zones does not respect pagnation
2 participants