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

CUSTESC-29915: unify output for rules without rule settings #2532

Merged
merged 6 commits into from
Jun 16, 2023

Conversation

alyssamw
Copy link
Contributor

@alyssamw alyssamw commented Jun 15, 2023

Closes #2085

@alyssamw alyssamw requested a review from jacobbednarz as a code owner June 15, 2023 21:59
@github-actions
Copy link
Contributor

github-actions bot commented Jun 15, 2023

changelog detected ✅

@alyssamw alyssamw force-pushed the alyssaw/CUSTESC-29915 branch from 0a6430d to fb2d9c1 Compare June 15, 2023 22:02
To ensure we always set the `rules_setting` values (even when we are aiming to
remove the setting) I've moved the `empty` logic into the
`flattenTeamsRuleSettings` method so that the Read/Create logic are using the
same source. This also fixes a logic bug in the comparison where a `!= nil`
should have been a `== nil`.
@jacobbednarz
Copy link
Member

jacobbednarz commented Jun 16, 2023

thanks for the PR here @alyssamw. i went ahead and pushed a couple of commits to address some issues i found here. details are in the commits but at a high level:

  • i moved the empty logic into the flattenTeamsRuleSettings method for two reasons. the first is that Read/Create need to use the same source for when to save the nested object in state. the second part is that we always want to call d.Set (regardless of whether we have values) to make sure we can clear the state if someone removes the values.
  • i extended the test logic to cover the second part of the first point but also found a logic bug in the empty logic where a != nil should have been a == nil.

ideally, we'd want to revisit some of these structs in cloudflare-go and better utilise pointers and omitempty to handle some of the falsey style checks we are currently aggregating to make it a bit easier to determine when something has been unset.

acceptance tests are now passing

TF_ACC=1 go test ./internal/sdkv2provider -v -run "^TestAccCloudflareTeamsRule_" -count 1 -timeout 120m -parallel 1
=== RUN   TestAccCloudflareTeamsRule_Basic
--- PASS: TestAccCloudflareTeamsRule_Basic (14.99s)
=== RUN   TestAccCloudflareTeamsRule_NoSettings
--- PASS: TestAccCloudflareTeamsRule_NoSettings (21.98s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider	38.044s

.changelog/2532.txt Outdated Show resolved Hide resolved
@jacobbednarz jacobbednarz merged commit 3209b99 into cloudflare:master Jun 16, 2023
@github-actions github-actions bot added this to the v4.9.0 milestone Jun 16, 2023
github-actions bot pushed a commit that referenced this pull request Jun 16, 2023
@github-actions
Copy link
Contributor

This functionality has been released in v4.9.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2023
@alyssamw alyssamw deleted the alyssaw/CUSTESC-29915 branch April 24, 2024 19:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cloudflare_teams_rule without rule_settings create a diff on every apply
2 participants