Skip to content

Commit

Permalink
security_center_subscription_pricing_resource: Fix disabled extension…
Browse files Browse the repository at this point in the history
…s logic

Signed-off-by: Ihab Zhaika <ihabzhaika@microsoft.com>
  • Loading branch information
Ihab-Zhaika committed Aug 17, 2023
1 parent bb58bf6 commit 3a8d168
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,27 @@ func resourceSecurityCenterSubscriptionPricingDelete(d *pluginsdk.ResourceData,
}

func expandSecurityCenterSubscriptionPricingExtensions(inputList []interface{}, extensionsStatusFromBackend *[]pricings_v2023_01_01.Extension) *[]pricings_v2023_01_01.Extension {
if len(inputList) == 0 {
return nil
}
var extensionStatuses = map[string]bool{}
var extensionProperties = map[string]*interface{}{}

var outputList []pricings_v2023_01_01.Extension
for _, v := range inputList {
input := v.(map[string]interface{})
extensionStatuses[input["name"].(string)] = true

if vAdditional, ok := input["additional_extension_properties"]; ok {
extensionProperties[input["name"].(string)] = &vAdditional
if extensionsStatusFromBackend != nil {
for _, backendExtension := range *extensionsStatusFromBackend {
// set the default value to false, then turn on the extension that appear in the template
extensionStatuses[backendExtension.Name] = false
}
}

if extensionsStatusFromBackend != nil {
for _, backendExtension := range *extensionsStatusFromBackend {
_, ok := extensionStatuses[backendExtension.Name]
// set any extension that does not appear in the template to be false
if !ok {
extensionStatuses[backendExtension.Name] = false
if inputList != nil {

Check failure on line 232 in internal/services/securitycenter/security_center_subscription_pricing_resource.go

View workflow job for this annotation

GitHub Actions / golint

S1031: unnecessary nil check around range (gosimple)
// set any extension in the template to be true
for _, v := range inputList {
input := v.(map[string]interface{})
if input["name"] == "" {
continue
}
extensionStatuses[input["name"].(string)] = true
if vAdditional, ok := input["additional_extension_properties"]; ok {
extensionProperties[input["name"].(string)] = &vAdditional
}
}
}
Expand Down

0 comments on commit 3a8d168

Please sign in to comment.