Skip to content

Commit

Permalink
fix: update types to match the SDK
Browse files Browse the repository at this point in the history
This updates some fields from int32 to int64 to match the
SDK.  Updating those types exposed an unnecessary use of VLAN
IDs as ASNs in the Metal Gateway tests; those references have
been replaced with a hard-coded ASN of 65100.
  • Loading branch information
ctreatma committed May 13, 2024
1 parent 2f76bc7 commit 61544c7
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/metal_gateway_create-bgp-dynamic-neighbors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metal gateway create-bgp-dynamic-neighbors [flags]
### Options

```
--asn int32 ASN for the BGP Dynamic Neighbor IP range.
--asn int ASN for the BGP Dynamic Neighbor IP range.
--bgp-neighbor-range string BGP Dynamic Neighbor IP Range from gateway.
-h, --help help for create-bgp-dynamic-neighbors
-i, --id string Metal Gateway ID for which the BGP Dynamic Neighbor to be created.
Expand Down
2 changes: 1 addition & 1 deletion docs/metal_vrf_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metal vrf create [-p <project_id] [-d <description>] [-m <metro>] [-n <name>] [-
-d, --description string Description of the Virtual Routing and Forwarding.
-h, --help help for create
-r, --ipranges strings A list of CIDR network addresses. Like [10.0.0.0/16, 2001:d78::/56]. IPv4 blocks must be between /8 and /29 in size. IPv6 blocks must be between /56 and /64.
-a, --local-asn int32 Local ASN for the VRF
-a, --local-asn int Local ASN for the VRF
-m, --metro string The UUID (or metro code) for the Metro in which to create this Virtual Routing and Forwarding
-n, --name string Name of the Virtual Routing and Forwarding
-p, --project-id string The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.
Expand Down
4 changes: 2 additions & 2 deletions internal/gateway/createbgpneighbours.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

func (c *Client) CreateBgpNeighbors() *cobra.Command {
var gatewayId, bgpNeighborRange string
var asn int32
var asn int64

// createGwBgpCmd represents the creation of gateway bgp dynamic neighbor command
createGwBgpCmd := &cobra.Command{
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c *Client) CreateBgpNeighbors() *cobra.Command {

createGwBgpCmd.Flags().StringVarP(&gatewayId, "id", "i", "", "Metal Gateway ID for which the BGP Dynamic Neighbor to be created.")
createGwBgpCmd.Flags().StringVar(&bgpNeighborRange, "bgp-neighbor-range", "", "BGP Dynamic Neighbor IP Range from gateway.")
createGwBgpCmd.Flags().Int32Var(&asn, "asn", 0, "ASN for the BGP Dynamic Neighbor IP range.")
createGwBgpCmd.Flags().Int64Var(&asn, "asn", 0, "ASN for the BGP Dynamic Neighbor IP range.")

_ = createGwBgpCmd.MarkFlagRequired("id")
return createGwBgpCmd
Expand Down
2 changes: 1 addition & 1 deletion internal/interconnections/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (c *Client) Create() *cobra.Command {
in := metal.NewVlanFabricVcCreateInput(
metro, name, redundancy, metal.VlanFabricVcCreateInputServiceTokenType(svcTokenType),
metal.VlanFabricVcCreateInputType(connType),
vlans,
)
in.Vlans = vlans
// default speed
in.SetSpeed(strconv.Itoa(int(speed)))

Expand Down
2 changes: 1 addition & 1 deletion internal/projects/bgpenable.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *Client) BGPEnable() *cobra.Command {
func enableBGP(c *Client, config *BgpConfig) error {
req := metal.BgpConfigRequestInput{
UseCase: &config.UseCase,
Asn: int32(config.ASN),
Asn: int64(config.ASN),
DeploymentType: metal.BgpConfigRequestInputDeploymentType(config.DeploymentType),
Md5: &config.MD5,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/virtualcircuit/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (c *Client) Create() *cobra.Command {
if err != nil {
return fmt.Errorf("%w", err)
}
vrfInput := metal.NewVrfVirtualCircuitCreateInput(int32(nnVlan), int32(peerAsn), projectID, subnet, vrf)
vrfInput := metal.NewVrfVirtualCircuitCreateInput(int32(nnVlan), int64(peerAsn), projectID, subnet, vrf)
setParams(vrfInput, name, description, tags)
createInput = createVrfVirtualCircuit(vrfInput, projectID, customerIP, metalIP, md5, speed)
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/virtualcircuit/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func updateVrfVirtualCircuit(vrfUpdateInput *metal.VrfVirtualCircuitUpdateInput,
vrfUpdateInput.SetCustomerIp(customerIP)

if peerAsn > 0 {
vrfUpdateInput.SetPeerAsn(int32(peerAsn))
vrfUpdateInput.SetPeerAsn(int64(peerAsn))
}

return metal.VirtualCircuitUpdateInput{VrfVirtualCircuitUpdateInput: vrfUpdateInput}
Expand Down
4 changes: 2 additions & 2 deletions internal/vrf/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *Client) Create() *cobra.Command {
name string
description string
ipRanges []string
localASN int32
localASN int64
tags []string
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func (c *Client) Create() *cobra.Command {
createVRFCmd.Flags().StringVarP(&description, "description", "d", "", "Description of the Virtual Routing and Forwarding.")

createVRFCmd.Flags().StringVarP(&metro, "metro", "m", "", "The UUID (or metro code) for the Metro in which to create this Virtual Routing and Forwarding")
createVRFCmd.Flags().Int32VarP(&localASN, "local-asn", "a", 0, "Local ASN for the VRF")
createVRFCmd.Flags().Int64VarP(&localASN, "local-asn", "a", 0, "Local ASN for the VRF")
createVRFCmd.Flags().StringSliceVarP(&ipRanges, "ipranges", "r", []string{}, "A list of CIDR network addresses. Like [10.0.0.0/16, 2001:d78::/56]. IPv4 blocks must be between /8 and /29 in size. IPv6 blocks must be between /56 and /64.")

// making them all required here
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gateways/bgp-dynamic-neighbour/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestBgpDynamicNeighbors_Create(t *testing.T) {

project := helper.CreateTestProject(t, projectName)
vlan := helper.CreateTestVLAN(t, project.GetId(), "da")
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, vlan.GetVxlan())
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, 65100)
vrfIpRes := helper.CreateTestVrfIpRequest(t, project.GetId(), vrf.GetId())
gway := helper.CreateTestVrfGateway(t, project.GetId(), vrfIpRes.VrfIpReservation.GetId(), vlan.GetId())

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gateways/bgp-dynamic-neighbour/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestBgpDynamicNeighbors_Delete(t *testing.T) {

project := helper.CreateTestProject(t, projectName)
vlan := helper.CreateTestVLAN(t, project.GetId(), "da")
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, vlan.GetVxlan())
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, 65100)
vrfIpRes := helper.CreateTestVrfIpRequest(t, project.GetId(), vrf.GetId())
gway := helper.CreateTestVrfGateway(t, project.GetId(), vrfIpRes.VrfIpReservation.GetId(), vlan.GetId())
bgpDynamicNeighbor := helper.CreateTestBgpDynamicNeighbor(t, gway.GetId(), gway.IpReservation.GetAddress(), 65000)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gateways/bgp-dynamic-neighbour/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestBgpDynamicNeighbors_Get(t *testing.T) {

project := helper.CreateTestProject(t, projectName)
vlan := helper.CreateTestVLAN(t, project.GetId(), "da")
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, vlan.GetVxlan())
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, 65100)
vrfIpRes := helper.CreateTestVrfIpRequest(t, project.GetId(), vrf.GetId())
gway := helper.CreateTestVrfGateway(t, project.GetId(), vrfIpRes.VrfIpReservation.GetId(), vlan.GetId())
bgpDynamicNeighbor := helper.CreateTestBgpDynamicNeighbor(t, gway.GetId(), gway.IpReservation.GetAddress(), 65000)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gateways/bgp-dynamic-neighbour/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestBgpDynamicNeighbors_List(t *testing.T) {

project := helper.CreateTestProject(t, projectName)
vlan := helper.CreateTestVLAN(t, project.GetId(), "da")
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, vlan.GetVxlan())
vrf := helper.CreateTestVrfs(t, project.GetId(), "test-vrf-"+randomStr, 65100)
vrfIpRes := helper.CreateTestVrfIpRequest(t, project.GetId(), vrf.GetId())
gway := helper.CreateTestVrfGateway(t, project.GetId(), vrfIpRes.VrfIpReservation.GetId(), vlan.GetId())
bgpDynamicNeighbor := helper.CreateTestBgpDynamicNeighbor(t, gway.GetId(), gway.IpReservation.GetAddress(), 65000)
Expand Down
8 changes: 4 additions & 4 deletions test/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func CleanTestOrganization(t *testing.T, orgId string) {
func CreateTestBgpEnableTest(projId string) error {
TestApiClient := TestClient()

bgpConfigRequestInput := *metalv1.NewBgpConfigRequestInput(int32(65000), metalv1.BgpConfigRequestInputDeploymentType("local"))
bgpConfigRequestInput := *metalv1.NewBgpConfigRequestInput(65000, metalv1.BgpConfigRequestInputDeploymentType("local"))

_, err := TestApiClient.BGPApi.RequestBgpConfig(context.Background(), projId).BgpConfigRequestInput(bgpConfigRequestInput).Execute()
if err != nil {
Expand Down Expand Up @@ -654,14 +654,14 @@ func waitForInterconnectionDeleted(apiClient *metalv1.APIClient, connId string,
}

//nolint:staticcheck
func CreateTestVrfs(t *testing.T, projectId, name string, vlan int32) *metalv1.Vrf {
func CreateTestVrfs(t *testing.T, projectId, name string, asn int64) *metalv1.Vrf {
t.Helper()
TestApiClient := TestClient()

var IpRanges []string

vrfCreateInput := *metalv1.NewVrfCreateInput("da", name)
vrfCreateInput.SetLocalAsn(vlan)
vrfCreateInput.SetLocalAsn(asn)
IpRanges = append(IpRanges, "10.10.1.0/24")
vrfCreateInput.SetIpRanges(IpRanges)

Expand Down Expand Up @@ -791,7 +791,7 @@ func CleanTestVrfGateway(t *testing.T, gatewayId string) {
}
}

func CreateTestBgpDynamicNeighbor(t *testing.T, gatewayId, iprange string, asn int32) *metalv1.BgpDynamicNeighbor {
func CreateTestBgpDynamicNeighbor(t *testing.T, gatewayId, iprange string, asn int64) *metalv1.BgpDynamicNeighbor {
TestApiClient := TestClient()
t.Helper()

Expand Down

0 comments on commit 61544c7

Please sign in to comment.