From 9c8e9a080eac95d4f9fd2965a7cf19773f4b87d0 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Tue, 3 Dec 2024 02:46:01 -0700 Subject: [PATCH] Fix lint errors and remove dependencies on utils package... --- .../cdn_frontdoor_firewall_policy_resource.go | 25 ++++++++-------- .../services/cdn/cdn_frontdoor_helpers.go | 29 ------------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go index b8dbbacd8a56..2abae70611d7 100644 --- a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go +++ b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { @@ -506,7 +505,7 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in t := d.Get("tags").(map[string]interface{}) payload := waf.WebApplicationFirewallPolicy{ - Location: utils.String(location.Normalize("Global")), + Location: pointer.To(location.Normalize("Global")), Sku: &waf.Sku{ Name: pointer.To(waf.SkuName(sku)), }, @@ -527,15 +526,15 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in } if redirectUrl != "" { - payload.Properties.PolicySettings.RedirectURL = utils.String(redirectUrl) + payload.Properties.PolicySettings.RedirectURL = pointer.To(redirectUrl) } if customBlockResponseBody != "" { - payload.Properties.PolicySettings.CustomBlockResponseBody = utils.String(customBlockResponseBody) + payload.Properties.PolicySettings.CustomBlockResponseBody = pointer.To(customBlockResponseBody) } if customBlockResponseStatusCode > 0 { - payload.Properties.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(customBlockResponseStatusCode)) + payload.Properties.PolicySettings.CustomBlockResponseStatusCode = pointer.To(int64(customBlockResponseStatusCode)) } err = client.PoliciesCreateOrUpdateThenPoll(ctx, id, payload) @@ -595,15 +594,15 @@ func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta in }) if redirectUrl := d.Get("redirect_url").(string); redirectUrl != "" { - props.PolicySettings.RedirectURL = utils.String(redirectUrl) + props.PolicySettings.RedirectURL = pointer.To(redirectUrl) } if body := d.Get("custom_block_response_body").(string); body != "" { - props.PolicySettings.CustomBlockResponseBody = utils.String(body) + props.PolicySettings.CustomBlockResponseBody = pointer.To(body) } if statusCode := d.Get("custom_block_response_status_code").(int64); statusCode > 0 { - props.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(statusCode)) + props.PolicySettings.CustomBlockResponseStatusCode = pointer.To(statusCode) } } @@ -755,12 +754,12 @@ func expandCdnFrontDoorFirewallCustomRules(input []interface{}) *waf.CustomRuleL action := custom["action"].(string) output = append(output, waf.CustomRule{ - Name: utils.String(name), + Name: pointer.To(name), Priority: priority, EnabledState: pointer.To(enabled), RuleType: waf.RuleType(ruleType), - RateLimitDurationInMinutes: utils.Int64(rateLimitDurationInMinutes), - RateLimitThreshold: utils.Int64(rateLimitThreshold), + RateLimitDurationInMinutes: pointer.To(rateLimitDurationInMinutes), + RateLimitThreshold: pointer.To(rateLimitThreshold), MatchConditions: matchConditions, Action: waf.ActionType(action), }) @@ -798,7 +797,7 @@ func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []waf.MatchC matchCondition.MatchVariable = waf.MatchVariable(matchVariable) } if selector != "" { - matchCondition.Selector = utils.String(selector) + matchCondition.Selector = pointer.To(selector) } result = append(result, matchCondition) @@ -985,7 +984,7 @@ func flattenCdnFrontDoorFirewallCustomRules(input *waf.CustomRuleList) []interfa priority := 0 if v.Priority != 0 { - priority = int(int(v.Priority)) + priority = int(v.Priority) } rateLimitDurationInMinutes := 0 diff --git a/internal/services/cdn/cdn_frontdoor_helpers.go b/internal/services/cdn/cdn_frontdoor_helpers.go index 0eabbd7fc0a8..fb2870744e8b 100644 --- a/internal/services/cdn/cdn_frontdoor_helpers.go +++ b/internal/services/cdn/cdn_frontdoor_helpers.go @@ -109,35 +109,6 @@ func flattenHttpsRedirectToBool(input cdn.HTTPSRedirect) bool { return input == cdn.HTTPSRedirectEnabled } -func expandFrontDoorTags(tagMap *map[string]string) map[string]*string { - t := make(map[string]*string) - - if tagMap != nil { - for k, v := range *tagMap { - tagKey := k - tagValue := v - t[tagKey] = &tagValue - } - } - - return t -} - -func flattenFrontDoorTags(tagMap map[string]*string) *map[string]string { - t := make(map[string]string) - - for k, v := range tagMap { - tagKey := k - tagValue := v - if tagValue == nil { - continue - } - t[tagKey] = *tagValue - } - - return &t -} - func flattenTransformSlice(input *[]waf.TransformType) []interface{} { result := make([]interface{}, 0) if input == nil || len(*input) == 0 {