Skip to content

Commit

Permalink
fix(ip_group_cidr): Fixed the position of the CIDR existence check (#…
Browse files Browse the repository at this point in the history
…27103)

* fix(ip_group_cidr): Fixed the pos of the CIDR existence check

* fix(ip_group_cidr): Prevent nil pointer dereference

---------

Co-authored-by: Bindewald, André (UIT) <[email protected]>
  • Loading branch information
tiwood and Bindewald, André (UIT) authored Aug 20, 2024
1 parent f0fe0ec commit 1997b61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/services/network/ip_group_cidr_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/ipgroups"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down Expand Up @@ -136,10 +137,11 @@ func resourceIpGroupCidrRead(d *pluginsdk.ResourceData, meta interface{}) error
if resp.Model.Properties == nil {
return fmt.Errorf("retrieving %s: `properties` was nil", ipGroupId)
}
if !utils.SliceContainsValue(*resp.Model.Properties.IPAddresses, cidr) {
d.SetId("")
return nil
}
}

if !utils.SliceContainsValue(pointer.From(resp.Model.Properties.IPAddresses), cidr) {
d.SetId("")
return nil
}

d.Set("ip_group_id", ipGroupId.ID())
Expand Down

0 comments on commit 1997b61

Please sign in to comment.