Skip to content

Commit

Permalink
Add IPAddress VPCNAT1To1 field
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai committed Oct 26, 2023
1 parent f150a51 commit f6d1828
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
27 changes: 18 additions & 9 deletions instance_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ type InstanceIPv4Response struct {

// InstanceIP represents an Instance IP with additional DNS and networking details
type InstanceIP struct {
Address string `json:"address"`
Gateway string `json:"gateway"`
SubnetMask string `json:"subnet_mask"`
Prefix int `json:"prefix"`
Type InstanceIPType `json:"type"`
Public bool `json:"public"`
RDNS string `json:"rdns"`
LinodeID int `json:"linode_id"`
Region string `json:"region"`
Address string `json:"address"`
Gateway string `json:"gateway"`
SubnetMask string `json:"subnet_mask"`
Prefix int `json:"prefix"`
Type InstanceIPType `json:"type"`
Public bool `json:"public"`
RDNS string `json:"rdns"`
LinodeID int `json:"linode_id"`
Region string `json:"region"`
VPCNAT1To1 *InstanceIPNAT1To1 `json:"vpc_nat_1_1"`
}

// InstanceIPv6Response contains the IPv6 addresses and ranges for an Instance
Expand All @@ -41,6 +42,14 @@ type InstanceIPv6Response struct {
Global []IPv6Range `json:"global"`
}

// InstanceIPNAT1To1 contains information about the NAT 1:1 mapping
// of a public IP address to a VPC subnet.
type InstanceIPNAT1To1 struct {
Address string `json:"address"`
SubnetID int `json:"subnet_id"`
VPCID int `json:"vpc_id"`
}

// IPv6Range represents a range of IPv6 addresses routed to a single Linode in a given Region
type IPv6Range struct {
Range string `json:"range"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interactions:
false}, {"region": "us-southeast", "plan": "premium65536.7", "available": false},
{"region": "us-southeast", "plan": "premium8192.7", "available": false}, {"region":
"us-southeast", "plan": "premium98304.7", "available": false}, {"region": "us-east",
"plan": "gpu-rtx6000-1.1", "available": true}, {"region": "us-east", "plan":
"plan": "gpu-rtx6000-1.1", "available": false}, {"region": "us-east", "plan":
"gpu-rtx6000-2.1", "available": false}, {"region": "us-east", "plan": "gpu-rtx6000-3.1",
"available": false}, {"region": "us-east", "plan": "gpu-rtx6000-4.1", "available":
false}, {"region": "us-east", "plan": "premium131072.7", "available": false},
Expand Down
3 changes: 3 additions & 0 deletions test/integration/instance_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func setupInstanceWith3Interfaces(t *testing.T, fixturesYaml string) (
{
Purpose: InterfacePurposeVPC,
SubnetID: &vpcSubnet.ID,
IPv4: &VPCIPv4{
NAT1To1: "all",
},
},
}
config, err = client.UpdateInstanceConfig(context.Background(), instance.ID, config.ID, updateConfigOpts)
Expand Down
16 changes: 16 additions & 0 deletions test/integration/vpc_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,20 @@ func TestVPC_Subnet_WithInstance(t *testing.T) {
if targetInterface.ID != config.Interfaces[2].ID {
t.Fatalf("interface ID mismatch, expected %d for %d", config.Interfaces[2].ID, targetInterface.ID)
}

if !targetInterface.Active {
t.Fatalf("expected interface to be active")
}

// Ensure the NAT 1:1 information is reflected in the IP configuration of this instance
networking, err := client.GetInstanceIPAddresses(context.Background(), inst.ID)
if err != nil {
t.Fatal(err)
}

nat1To1 := networking.IPv4.Public[0].VPCNAT1To1

if nat1To1 == nil {
t.Fatalf("expected VPCNAT1To1 to contain data, got nil")
}
}

0 comments on commit f6d1828

Please sign in to comment.