Skip to content

Commit

Permalink
Fix lint errors and remove dependencies on utils package...
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon committed Dec 3, 2024
1 parent 4304808 commit 9c8e9a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
25 changes: 12 additions & 13 deletions internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)),
},
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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),
})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
29 changes: 0 additions & 29 deletions internal/services/cdn/cdn_frontdoor_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9c8e9a0

Please sign in to comment.