-
Notifications
You must be signed in to change notification settings - Fork 615
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
zone: allow ListZonesContext
to automatically handle pagination
#534
Conversation
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
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.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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. |
Updates the
ListZonesContext
method to automatically handle thepagination 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