Skip to content

Commit

Permalink
Merge pull request #1156 from cloudflare/reset-struct-on-each-loop
Browse files Browse the repository at this point in the history
firewall_rules/filter: reset fResponse on each loop to avoid residual data
  • Loading branch information
jacobbednarz authored Dec 29, 2022
2 parents ef3d061 + 50908bb commit 7800dcf
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .changelog/1156.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
```release-note:bug
firewall_rules: use empty reponse struct on each page call
```

```release-note:bug
filter: use empty reponse struct on each page call
```

```release-note:bug
email_routing_destination: use empty reponse struct on each page call
```

```release-note:bug
email_routing_rules: use empty reponse struct on each page call
```

```release-note:bug
lockdown: use empty reponse struct on each page call
```

```release-note:bug
queue: use empty reponse struct on each page call
```

```release-note:bug
teams_list: use empty reponse struct on each page call
```

```release-note:bug
workers_kv: use empty reponse struct on each page call
```
1 change: 1 addition & 0 deletions email_routing_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (api *API) ListEmailRoutingDestinationAddresses(ctx context.Context, rc *Re
var addresses []EmailRoutingDestinationAddress
var eResponse ListEmailRoutingAddressResponse
for {
eResponse = ListEmailRoutingAddressResponse{}
uri := buildURI(fmt.Sprintf("/accounts/%s/email/routing/addresses", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
1 change: 1 addition & 0 deletions email_routing_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (api *API) ListEmailRoutingRules(ctx context.Context, rc *ResourceContainer
var rules []EmailRoutingRule
var rResponse ListEmailRoutingRuleResponse
for {
rResponse = ListEmailRoutingRuleResponse{}
uri := buildURI(fmt.Sprintf("/zones/%s/email/routing/rules", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
1 change: 1 addition & 0 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (api *API) Filters(ctx context.Context, rc *ResourceContainer, params Filte
var filters []Filter
var fResponse FiltersDetailResponse
for {
fResponse = FiltersDetailResponse{}
uri := buildURI(fmt.Sprintf("/zones/%s/filters", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
1 change: 1 addition & 0 deletions firewall_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (api *API) FirewallRules(ctx context.Context, rc *ResourceContainer, params
var firewallRules []FirewallRule
var fResponse FirewallRulesDetailResponse
for {
fResponse = FirewallRulesDetailResponse{}
uri := buildURI(fmt.Sprintf("/zones/%s/firewall/rules", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
1 change: 1 addition & 0 deletions lockdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (api *API) ListZoneLockdowns(ctx context.Context, rc *ResourceContainer, pa
var zoneLockdowns []ZoneLockdown
var zResponse ZoneLockdownListResponse
for {
zResponse = ZoneLockdownListResponse{}
uri := buildURI(fmt.Sprintf("/zones/%s/firewall/lockdowns", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
2 changes: 2 additions & 0 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (api *API) ListQueues(ctx context.Context, rc *ResourceContainer, params Li
var queues []Queue
var qResponse QueueListResponse
for {
qResponse = QueueListResponse{}
uri := buildURI(fmt.Sprintf("/accounts/%s/workers/queues", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down Expand Up @@ -276,6 +277,7 @@ func (api *API) ListQueueConsumers(ctx context.Context, rc *ResourceContainer, p
var queuesConsumers []QueueConsumer
var qResponse ListQueueConsumersResponse
for {
qResponse = ListQueueConsumersResponse{}
uri := buildURI(fmt.Sprintf("/accounts/%s/workers/queues/%s/consumers", rc.Identifier, params.QueueName), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
1 change: 1 addition & 0 deletions teams_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func (api *API) ListTeamsListItems(ctx context.Context, rc *ResourceContainer, p
var teamListItems []TeamsListItem
var lResponse TeamsListItemsListResponse
for {
lResponse = TeamsListItemsListResponse{}
uri := buildURI(
fmt.Sprintf("/%s/%s/gateway/lists/%s/items", rc.Level, rc.Identifier, params.ListID),
params,
Expand Down
1 change: 1 addition & 0 deletions workers_kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (api *API) ListWorkersKVNamespaces(ctx context.Context, rc *ResourceContain
var namespaces []WorkersKVNamespace
var nsResponse ListWorkersKVNamespacesResponse
for {
nsResponse = ListWorkersKVNamespacesResponse{}
uri := buildURI(fmt.Sprintf("/accounts/%s/storage/kv/namespaces", rc.Identifier), params)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down

0 comments on commit 7800dcf

Please sign in to comment.