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

azurerm_web_application_firewall_policy: upgrade API version to 2023-02-01 #22455

Merged
merged 7 commits into from
Jul 28, 2023

Conversation

wuxu92
Copy link
Contributor

@wuxu92 wuxu92 commented Jul 11, 2023

Draft for TC

--- PASS: TestAccWebApplicationFirewallPolicy_basic (276.18s)
--- PASS: TestAccWebApplicationFirewallPolicy_complete (275.88s)
--- PASS: TestAccWebApplicationFirewallPolicy_update (293.06s)
--- PASS: TestAccWebApplicationFirewallPolicy_updateOverrideRules (336.83s)
--- PASS: TestAccWebApplicationFirewallPolicy_knownCVEs (278.11s)
--- PASS: TestAccWebApplicationFirewallPolicy_OperatorAny (274.98s)
--- PASS: TestAccWebApplicationFirewallPolicy_excludedRules (309.16s)
--- PASS: TestAccWebApplicationFirewallPolicy_updateDisabledRules (312.72s)
PASS

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @wuxu92

Thanks for this PR - I've taken a look through and left some comments inline, but if we can fix those up then this should otherwise be good to go 👍

Thanks!

Comment on lines 529 to 536
future, err := client.Delete(ctx, *id)
if err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
if err = future.Poller.PollUntilDone(ctx); err != nil {
return fmt.Errorf("waiting for the deletion of %s: %+v", *id, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we can reduce this to: `if err := client.DeleteThenPoll(...); err != nil { ... }

Comment on lines 493 to 495
if location := model.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be reduced to:

Suggested change
if location := model.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
d.Set("location", location.NormalizeNilable(model.Location))

@@ -680,8 +684,8 @@ func expandWebApplicationFirewallPolicyExclusions(input []interface{}) *[]networ
return &results
}

func expandWebApplicationFirewallPolicyManagedRuleSet(input []interface{}, d *pluginsdk.ResourceData) (*[]network.ManagedRuleSet, error) {
results := make([]network.ManagedRuleSet, 0)
func expandWebApplicationFirewallPolicyManagedRuleSet(input []interface{}, d *pluginsdk.ResourceData) ([]webapplicationfirewallpolicies.ManagedRuleSet, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we always return a pointer and an error when an error is returned too:

Suggested change
func expandWebApplicationFirewallPolicyManagedRuleSet(input []interface{}, d *pluginsdk.ResourceData) ([]webapplicationfirewallpolicies.ManagedRuleSet, error) {
func expandWebApplicationFirewallPolicyManagedRuleSet(input []interface{}, d *pluginsdk.ResourceData) (*[]webapplicationfirewallpolicies.ManagedRuleSet, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

slice can function as a pointer in many instances, though it is not a pointer. I'll update it to a pointer to slice to make it the same as others.

@@ -791,8 +795,8 @@ func expandWebApplicationFirewallPolicyOverrideRules(input []interface{}) *[]net
return &results
}

func expandWebApplicationFirewallPolicyMatchCondition(input []interface{}) *[]network.MatchCondition {
results := make([]network.MatchCondition, 0)
func expandWebApplicationFirewallPolicyMatchCondition(input []interface{}) []webapplicationfirewallpolicies.MatchCondition {
Copy link
Contributor

Choose a reason for hiding this comment

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

(same here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function will not return with an error, so do not need a pointer to slice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe the expand functions should return a pointer only when the SDK Field is a pointer too? or we always return a pointer no matter what the SDK is?

if err != nil {
return nil, fmt.Errorf("reading %s: %+v", *id, err)
}

return utils.Bool(resp.ID != nil), nil
return utils.Bool(resp.Model.Id != nil), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return utils.Bool(resp.Model.Id != nil), nil
return utils.Bool(resp.Model != nil), nil

@wuxu92
Copy link
Contributor Author

wuxu92 commented Jul 13, 2023

Tests pass now:
image

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 🕸️

@katbyte
Copy link
Collaborator

katbyte commented Jul 25, 2023

@wuxu92 - could you fix up the build?

@wuxu92
Copy link
Contributor Author

wuxu92 commented Jul 26, 2023

@wuxu92 Xu Wu FTE - could you fix up the build?

@katbyte updated.

@tombuildsstuff
Copy link
Contributor

@wuxu92 hope you don't mind but I've rebased this atop of main and updated this to use the Meta Client, since this is now available as of #22676

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

One minor comment that I'm going to push a commit to fix, but this otherwise LGTM - thanks @wuxu92

@tombuildsstuff tombuildsstuff added this to the v3.68.0 milestone Jul 28, 2023
@wuxu92
Copy link
Contributor Author

wuxu92 commented Jul 28, 2023

@tombuildsstuff of course not! thanks!

@tombuildsstuff tombuildsstuff merged commit 17c2a5a into hashicorp:main Jul 28, 2023
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants