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

Rate limit for zone resource #30

Merged
merged 6 commits into from
Mar 9, 2018
Merged

Conversation

benjvi
Copy link
Contributor

@benjvi benjvi commented Feb 26, 2018

Adds the new resource and updates the cloudflare-go library to a recent version

Partially due to the way structured maps are (not) handled in terraform the expanding/flattening logic is pretty long for the nested attributes. I've split things out so hopefully its a bit clearer. The only other change from the go client should be that bypass_url_patterns was specified as a key-value struct, here its simplified as a string list.

Since we need both zone + resource id to do lookups the ID is a amalgamation of the two, and we generate two computed fields for the separate zone + resource ids which is what I refer to in any operations after read. Hopefully this makes sense - this approach not common since normally resource id is sufficient for lookups but there is some prior art in the AWS provider for this

Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

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

Hi there! The size of this pull request makes it very difficult to review. If possible please extract the changes to the included vendor folder into it's own Pull Request.

The same applies to https://github.com/terraform-providers/terraform-provider-cloudflare/pull/31

Please let me know if that is not possible.

@benjvi
Copy link
Contributor Author

benjvi commented Feb 28, 2018

@catsby Is the separate PR in #32 with this rebased on top enough to make this easier to review?

@catsby
Copy link
Contributor

catsby commented Mar 2, 2018

@benjvi well, it should have, but I merged #32 and this is still very large. Perhaps I did the merge wrong, by making a merge commit.

Would it be possible to rebase again off of master now?

Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

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

LGTM, just need to check errors when setting TypeList, TypeSet, TypeMap, etc.

d.Set("threshold", rateLimit.Threshold)
d.Set("period", rateLimit.Period)
d.Set("match", flattenRateLimitTrafficMatcher(rateLimit.Match))
d.Set("action", flattenRateLimitAction(rateLimit.Action))
Copy link
Contributor

Choose a reason for hiding this comment

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

Errors need to be checked when setting non-scalar attributes such as action and match:

if err := d.Set("action", ...); err != nil {
  log.Printf("[WARN] Error setting action: %s", err)
}

@benjvi benjvi force-pushed the zone-rate-limits branch from 4daa72c to 117e978 Compare March 5, 2018 10:32
@benjvi
Copy link
Contributor Author

benjvi commented Mar 5, 2018

@catsby I updated with your comments. Also I changed the ID a bit so it could be consistent with the existing DNS record resource + a bit more intuitive ( it also seems that underscore is relatively common in subdomains so I changed the separator to "/" on import )

Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@catsby catsby merged commit 4358a40 into cloudflare:master Mar 9, 2018
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.

2 participants