diff --git a/equinix/data_source_network_device.go b/equinix/data_source_network_device.go index f63670dd0..121689512 100644 --- a/equinix/data_source_network_device.go +++ b/equinix/data_source_network_device.go @@ -3,6 +3,7 @@ package equinix import ( "context" "fmt" + "slices" "strings" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -686,7 +687,7 @@ func dataSourceNetworkDeviceRead(ctx context.Context, d *schema.ResourceData, m return diag.Errorf("cannot fetch primary network device due to '%v'", err) } - if isStringInSlice(ne.StringValue(primary.Status), []string{ne.DeviceStateDeprovisioning, ne.DeviceStateDeprovisioned}) { + if slices.Contains([]string{ne.DeviceStateDeprovisioning, ne.DeviceStateDeprovisioned}, ne.StringValue(primary.Status)) { d.SetId("") return diags } diff --git a/equinix/provider.go b/equinix/provider.go index 199744767..ae6bea574 100644 --- a/equinix/provider.go +++ b/equinix/provider.go @@ -3,6 +3,7 @@ package equinix import ( "context" "fmt" + "slices" "strings" "time" @@ -195,7 +196,7 @@ func configureProvider(ctx context.Context, d *schema.ResourceData, p *schema.Pr func stringsFound(source []string, target []string) bool { for i := range source { - if !isStringInSlice(source[i], target) { + if !slices.Contains(target, source[i]) { return false } } @@ -204,16 +205,7 @@ func stringsFound(source []string, target []string) bool { func atLeastOneStringFound(source []string, target []string) bool { for i := range source { - if isStringInSlice(source[i], target) { - return true - } - } - return false -} - -func isStringInSlice(needle string, hay []string) bool { - for i := range hay { - if needle == hay[i] { + if slices.Contains(target, source[i]) { return true } } diff --git a/equinix/resource_ecx_l2_connection.go b/equinix/resource_ecx_l2_connection.go index 8db6f778f..17bebb200 100644 --- a/equinix/resource_ecx_l2_connection.go +++ b/equinix/resource_ecx_l2_connection.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "slices" "strings" "time" @@ -714,12 +715,12 @@ func resourceECXL2ConnectionRead(ctx context.Context, d *schema.ResourceData, m if err != nil { return diag.Errorf("cannot fetch primary connection due to %v", err) } - if isStringInSlice(ecx.StringValue(primary.Status), []string{ + if slices.Contains([]string{ ecx.ConnectionStatusPendingDelete, ecx.ConnectionStatusDeprovisioning, ecx.ConnectionStatusDeprovisioned, ecx.ConnectionStatusDeleted, - }) { + }, ecx.StringValue(primary.Status)) { d.SetId("") return diags } diff --git a/equinix/resource_network_device.go b/equinix/resource_network_device.go index 65ee573f0..dc1269e01 100644 --- a/equinix/resource_network_device.go +++ b/equinix/resource_network_device.go @@ -7,6 +7,7 @@ import ( "log" "os" "path/filepath" + "slices" "time" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -972,7 +973,7 @@ func resourceNetworkDeviceRead(ctx context.Context, d *schema.ResourceData, m in if err != nil { return diag.Errorf("cannot fetch primary network device due to %v", err) } - if isStringInSlice(ne.StringValue(primary.Status), []string{ne.DeviceStateDeprovisioning, ne.DeviceStateDeprovisioned}) { + if slices.Contains([]string{ne.DeviceStateDeprovisioning, ne.DeviceStateDeprovisioned}, ne.StringValue(primary.Status)) { d.SetId("") return diags }