diff --git a/go.mod b/go.mod index 89f4cffd1..179c442ba 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/antihax/optional v1.0.0 github.com/equinix-labs/fabric-go v0.7.1 github.com/equinix/ecx-go/v2 v2.3.1 - github.com/equinix/equinix-sdk-go v0.31.0 + github.com/equinix/equinix-sdk-go v0.32.1-0.20240125204450-f22739ace0f7 github.com/equinix/ne-go v1.13.0 github.com/equinix/oauth2-go v1.0.0 github.com/equinix/rest-go v1.3.0 diff --git a/go.sum b/go.sum index df6db169a..e564aae6c 100644 --- a/go.sum +++ b/go.sum @@ -267,8 +267,12 @@ github.com/equinix-labs/fabric-go v0.7.1 h1:4yk0IKXMcc72rkRVbcYHokAEc1uUB06t6NXK github.com/equinix-labs/fabric-go v0.7.1/go.mod h1:oqgGS3GOI8hHGPJKsAwDOEX0qRHl52sJGvwA/zMSd90= github.com/equinix/ecx-go/v2 v2.3.1 h1:gFcAIeyaEUw7S8ebqApmT7E/S7pC7Ac3wgScp89fkPU= github.com/equinix/ecx-go/v2 v2.3.1/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= -github.com/equinix/equinix-sdk-go v0.31.0 h1:BVD67nmpPEutsCGkYDuy0rykGNeQ5H3FIX+Dz5DpP7w= -github.com/equinix/equinix-sdk-go v0.31.0/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125194110-4088361fa6b7 h1:ipZkrpVU3xPEJp6uKkrDlDeEKGNkUNExtsAuHeakK4Q= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125194110-4088361fa6b7/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125200831-02238d07a989 h1:tP2wIfYuDq6u/4rWf8uj8fYQTzRjmt9RCXki2S7aoaA= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125200831-02238d07a989/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125204450-f22739ace0f7 h1:dGAlmpIXO+rtcVbI1+TKJVwkSpPG5X56ZeVur8xHpYM= +github.com/equinix/equinix-sdk-go v0.32.1-0.20240125204450-f22739ace0f7/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ= github.com/equinix/ne-go v1.13.0 h1:7mcEGnASjPVc2la/Q2WRCn2PcFVO3syXAd6YOU1lETw= github.com/equinix/ne-go v1.13.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI= github.com/equinix/oauth2-go v1.0.0 h1:fHtAPGq82PdgtK5vEThs8Vwz6f7D/8SX4tE3NJu+KcU= diff --git a/internal/resources/metal/vlan/datasource.go b/internal/resources/metal/vlan/datasource.go index ad27e608b..91ea80040 100644 --- a/internal/resources/metal/vlan/datasource.go +++ b/internal/resources/metal/vlan/datasource.go @@ -129,7 +129,7 @@ func dataSourceMetalVlanRead(ctx context.Context, d *schema.ResourceData, meta i "vlan_id": vlan.GetId(), "project_id": vlan.AssignedTo.GetId(), // vlan assigned_to is an href; should be project? "vxlan": vlan.GetVxlan(), - "facility": vlan.FacilityCode, // facility is deprecated, vlan is metro-scoped; remove this attr? + "facility": nil, //vlan.FacilityCode, // facility is deprecated, vlan is metro-scoped; remove this attr? "metro": vlan.MetroCode, "description": vlan.Description, })) diff --git a/internal/resources/metal/vlan/datasource_test.go b/internal/resources/metal/vlan/datasource_test.go index b41bd3312..03c297e51 100644 --- a/internal/resources/metal/vlan/datasource_test.go +++ b/internal/resources/metal/vlan/datasource_test.go @@ -251,15 +251,6 @@ func TestMetalVlan_MatchingVlan(t *testing.T) { want: &metalv1.VirtualNetwork{Vxlan: metalv1.PtrInt32(123)}, wantErr: false, }, - { - name: "MatchingFac", - args: args{ - vlans: []metalv1.VirtualNetwork{{FacilityCode: "fac"}}, - facility: "fac", - }, - want: &metalv1.VirtualNetwork{FacilityCode: "fac"}, - wantErr: false, - }, { name: "MatchingMet", args: args{ @@ -272,7 +263,7 @@ func TestMetalVlan_MatchingVlan(t *testing.T) { { name: "SecondMatch", args: args{ - vlans: []metalv1.VirtualNetwork{{FacilityCode: "fac"}, {MetroCode: metalv1.PtrString("met")}}, + vlans: []metalv1.VirtualNetwork{{MetroCode: metalv1.PtrString("fac")}, {MetroCode: metalv1.PtrString("met")}}, metro: "met", }, want: &metalv1.VirtualNetwork{MetroCode: metalv1.PtrString("met")}, @@ -290,10 +281,10 @@ func TestMetalVlan_MatchingVlan(t *testing.T) { { name: "ComplexMatch", args: args{ - vlans: []metalv1.VirtualNetwork{{Vxlan: metalv1.PtrInt32(987), FacilityCode: "fac", MetroCode: metalv1.PtrString("skip")}, {VXLAN: metalv1.PtrInt32(123), FacilityCode: "fac", MetroCode: metalv1.PtrString("met")}, {Vxlan: metalv1.PtrInt32(456), FacilityCode: "fac", MetroCode: metalv1.PtrString("nope")}}, + vlans: []metalv1.VirtualNetwork{{Vxlan: metalv1.PtrInt32(987), MetroCode: metalv1.PtrString("skip")}, {Vxlan: metalv1.PtrInt32(123), MetroCode: metalv1.PtrString("met")}, {Vxlan: metalv1.PtrInt32(456), MetroCode: metalv1.PtrString("nope")}}, metro: "met", }, - want: &metalv1.VirtualNetwork{Vxlan: metalv1.PtrInt32(123), FacilityCode: "fac", MetroCode: metalv1.PtrString("met")}, + want: &metalv1.VirtualNetwork{Vxlan: metalv1.PtrInt32(123), MetroCode: metalv1.PtrString("met")}, wantErr: false, }, { diff --git a/internal/resources/metal/vlan/matcher.go b/internal/resources/metal/vlan/matcher.go index 05c1634fa..85f891b93 100644 --- a/internal/resources/metal/vlan/matcher.go +++ b/internal/resources/metal/vlan/matcher.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/equinix/equinix-sdk-go/services/metalv1" - equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" ) func MatchingVlan(vlans []metalv1.VirtualNetwork, vxlan int, projectID, facility, metro string) (*metalv1.VirtualNetwork, error) { @@ -13,20 +12,20 @@ func MatchingVlan(vlans []metalv1.VirtualNetwork, vxlan int, projectID, facility if vxlan != 0 && int(v.GetVxlan()) != vxlan { continue } - if facility != "" && v.FacilityCode != facility { + /*if facility != "" && v.FacilityCode != facility { continue - } + }*/ if metro != "" && v.GetMetroCode() != metro { continue } matches = append(matches, v) } if len(matches) > 1 { - return nil, equinix_errors.FriendlyError(fmt.Errorf("Project %s has more than one matching VLAN", projectID)) + return nil, fmt.Errorf("Project %s has more than one matching VLAN", projectID) } if len(matches) == 0 { - return nil, equinix_errors.FriendlyError(fmt.Errorf("Project %s does not have matching VLANs", projectID)) + return nil, fmt.Errorf("Project %s does not have matching VLANs", projectID) } return &matches[0], nil } diff --git a/internal/resources/metal/vlan/resource.go b/internal/resources/metal/vlan/resource.go index 9406cbb50..e943bd12a 100644 --- a/internal/resources/metal/vlan/resource.go +++ b/internal/resources/metal/vlan/resource.go @@ -86,16 +86,16 @@ func resourceMetalVlanCreate(ctx context.Context, d *schema.ResourceData, meta i meta.(*config.Config).AddModuleToMetalGoUserAgent(d) client := meta.(*config.Config).Metalgo - facRaw, facOk := d.GetOk("facility") + //facRaw, facOk := d.GetOk("facility") metroRaw, metroOk := d.GetOk("metro") - vxlanRaw, vxlanOk := d.GetOk("vxlan") + vxlanRaw, _ := d.GetOk("vxlan") - if !facOk && !metroOk { + if /*!facOk &&*/ !metroOk { return diag.Errorf("one of facility or metro must be configured") } - if facOk && vxlanOk { + /*if facOk && vxlanOk { return diag.Errorf("you can set vxlan only for metro vlans") - } + }*/ createRequest := metalv1.VirtualNetworkCreateInput{ Description: metalv1.PtrString(d.Get("description").(string)), @@ -104,9 +104,9 @@ func resourceMetalVlanCreate(ctx context.Context, d *schema.ResourceData, meta i createRequest.Metro = metalv1.PtrString(metroRaw.(string)) createRequest.Vxlan = metalv1.PtrInt32(int32(vxlanRaw.(int))) } - if facOk { + /*if facOk { createRequest.Facility = facRaw.(string) - } + }*/ vlan, _, err := client.VLANsApi.CreateVirtualNetwork(ctx, d.Get("project_id").(string)).VirtualNetworkCreateInput(createRequest).Execute() if err != nil { return diag.FromErr(equinix_errors.FriendlyError(err)) @@ -133,7 +133,7 @@ func resourceMetalVlanRead(ctx context.Context, d *schema.ResourceData, meta int d.Set("description", vlan.Description) d.Set("project_id", vlan.AssignedTo.GetId()) // assigned_to is a project but specced as an href d.Set("vxlan", vlan.GetVxlan()) - d.Set("facility", vlan.FacilityCode) // vlan spec does not include facility_code; should we remove it? + //d.Set("facility", vlan.FacilityCode) // vlan spec does not include facility_code; should we remove it? d.Set("metro", vlan.MetroCode) return nil } @@ -154,10 +154,10 @@ func resourceMetalVlanDelete(ctx context.Context, d *schema.ResourceData, meta i // all device ports must be unassigned before delete for _, i := range vlan.Instances { for _, p := range i.NetworkPorts { // instances is specced as a list of href; should be devices? - for _, a := range p.AttachedVirtualNetworks { + for _, a := range p.VirtualNetworks { // ...aaaand device virtual_network is also an href // a.ID is not set despite including instaces.network_ports.virtual_networks // TODO(displague) packngo should offer GetID() that uses ID or Href - aID := path.Base(a.Href) + aID := path.Base(a.GetHref()) if aID == id { portInput := metalv1.PortAssignInput{