Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Add VPC to InstanceIPv4Response #465

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions instance_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type InstanceIPv4Response struct {
Private []*InstanceIP `json:"private"`
Shared []*InstanceIP `json:"shared"`
Reserved []*InstanceIP `json:"reserved"`
VPC []*VPCIP `json:"vpc"`
}

// InstanceIP represents an Instance IP with additional DNS and networking details
Expand All @@ -35,6 +36,23 @@ type InstanceIP struct {
VPCNAT1To1 *InstanceIPNAT1To1 `json:"vpc_nat_1_1"`
}

// VPCIP represents a private IP address in a VPC subnet with additional networking details
type VPCIP struct {
Address *string `json:"address"`
AddressRange *string `json:"address_range"`
Gateway string `json:"gateway"`
SubnetMask string `json:"subnet_mask"`
Prefix int `json:"prefix"`
LinodeID int `json:"linode_id"`
Region string `json:"region"`
Active bool `json:"active"`
NAT1To1 *string `json:"nat_1_1"`
VPCID int `json:"vpc_id"`
SubnetID int `json:"subnet_id"`
ConfigID int `json:"config_id"`
InterfaceID int `json:"interface_id"`
}

// InstanceIPv6Response contains the IPv6 addresses and ranges for an Instance
type InstanceIPv6Response struct {
LinkLocal *InstanceIP `json:"link_local"`
Expand Down
550 changes: 460 additions & 90 deletions test/integration/fixtures/TestIPAddresses_Instance_Get.yaml

Large diffs are not rendered by default.

394 changes: 271 additions & 123 deletions test/integration/fixtures/TestIPAddresses_List.yaml

Large diffs are not rendered by default.

435 changes: 305 additions & 130 deletions test/integration/fixtures/TestIPv6Range_Share.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/integration/instance_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func setupInstanceWith3Interfaces(t *testing.T, fixturesYaml string) (
t,
fixturesYaml,
func(client *Client, opts *InstanceCreateOptions) {
opts.Region = getRegionsWithCaps(t, client, []string{"VPCs"})[0]
opts.Region = getRegionsWithCaps(t, client, []string{"Linodes", "VPCs"})[0]
},
)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions test/integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ func TestInstance_Disk_ListMultiple(t *testing.T) {
Label: "go-disk-test-" + randLabel(),
Size: 2000,
})

if err != nil {
t.Errorf("Error creating disk after a private image: %s", err)
}
Expand Down Expand Up @@ -357,7 +356,6 @@ func TestInstance_Rebuild(t *testing.T) {
}

_, err = client.WaitForEventFinished(context.Background(), instance.ID, linodego.EntityLinode, linodego.ActionLinodeCreate, *instance.Created, 180)

if err != nil {
t.Errorf("Error waiting for instance created: %s", err)
}
Expand All @@ -371,7 +369,6 @@ func TestInstance_Rebuild(t *testing.T) {
Type: "g6-standard-2",
}
instance, err = client.RebuildInstance(context.Background(), instance.ID, rebuildOpts)

if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -404,7 +401,6 @@ func TestInstance_Clone(t *testing.T) {
*instance.Created,
180,
)

if err != nil {
t.Errorf("Error waiting for instance created: %s", err)
}
Expand Down Expand Up @@ -435,7 +431,6 @@ func TestInstance_Clone(t *testing.T) {
*clonedInstance.Created,
240,
)

if err != nil {
t.Fatal(err)
}
Expand Down
16 changes: 6 additions & 10 deletions test/integration/network_ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ func TestIPAddresses_List_smoke(t *testing.T) {
}

func TestIPAddresses_Instance_Get(t *testing.T) {
client, instance, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestIPAddresses_Instance_Get")
client, _, _, instance, config, teardown := setupInstanceWith3Interfaces(t, "fixtures/TestIPAddresses_Instance_Get")
defer teardown()
if err != nil {
t.Errorf("Error creating IPAddress test Instance, got error %v", err)
}

i, err := client.GetInstanceIPAddresses(context.Background(), instance.ID)
if err != nil {
t.Errorf("Error listing ipaddresses, expected struct, got error %v", err)
}
if i.IPv4.Public[0].Address != instance.IPv4[0].String() {
t.Errorf("Expected matching ipaddresses with GetInstanceIPAddress Instance IPAddress but got %v", i)
t.Errorf("Expected matching public IP ipaddresses with GetInstanceIPAddress Instance IPAddress but got %v", i)
}
if *i.IPv4.VPC[0].Address != config.Interfaces[2].IPv4.VPC {
t.Errorf("Expected matching VPC IP addresses with GetInstanceIPAddress Instance IPAddress but got %v", i)
}
}

Expand Down Expand Up @@ -229,11 +229,7 @@ func TestIPAddress_Instance_Assign(t *testing.T) {
}

func TestIPAddress_Instance_Share(t *testing.T) {
client, instance, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestIPAddress_Instance_Share", func(client *Client, options *InstanceCreateOptions) {
// This should stay hardcoded at the moment as the
// IP sharing rollout does not have a corresponding capability.
options.Region = "us-ord"
})
client, instance, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestIPAddress_Instance_Share")
defer teardown()
if err != nil {
t.Error(err)
Expand Down
2 changes: 0 additions & 2 deletions test/integration/network_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func TestIPv6Range_Share(t *testing.T) {
strings.TrimSuffix(ipRange.Range, "/64"),
},
})

if err != nil {
t.Fatal(err)
}
Expand All @@ -98,7 +97,6 @@ func TestIPv6Range_Share(t *testing.T) {
strings.TrimSuffix(ipRange.Range, "/64"),
},
})

if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 0 additions & 1 deletion test/integration/nodebalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestNodeBalancer_Update(t *testing.T) {
Label: &renamedLabel,
}
nodebalancer, err = client.UpdateNodeBalancer(context.Background(), nodebalancer.ID, updateOpts)

if err != nil {
t.Errorf("Error renaming nodebalancer, %s", err)
}
Expand Down
1 change: 0 additions & 1 deletion test/integration/object_storage_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func TestObjectStorageKey_Update(t *testing.T) {
Label: renamedLabel,
}
objectStorageKey, err = client.UpdateObjectStorageKey(context.Background(), objectStorageKey.ID, updateOpts)

if err != nil {
t.Errorf("Error renaming objectStorageKey, %s", err)
}
Expand Down
1 change: 0 additions & 1 deletion test/integration/profile_sshkeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func TestSSHKey_Update(t *testing.T) {
Label: renamedLabel,
}
sshkey, err = client.UpdateSSHKey(context.Background(), sshkey.ID, updateOpts)

if err != nil {
t.Errorf("Error renaming sshkey, %s", err)
}
Expand Down
1 change: 0 additions & 1 deletion test/integration/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func TestVolume_WaitForLinodeID_nil(t *testing.T) {
t.Errorf("Error setting up volume test, %s", err)
}
_, err = client.WaitForVolumeLinodeID(context.Background(), volume.ID, nil, 20)

if err != nil {
t.Errorf("Error getting volume %d, expected *LinodeVolume, got error %v", volume.ID, err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/vpc_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func createVPCWithSubnet(t *testing.T, client *linodego.Client, vpcModifier ...v
t.Helper()
createOpts := linodego.VPCCreateOptions{
Label: "go-test-vpc-" + getUniqueText(),
Region: getRegionsWithCaps(t, client, []string{"VPCs"})[0],
Region: getRegionsWithCaps(t, client, []string{"Linodes", "VPCs"})[0],
Subnets: []VPCSubnetCreateOptions{
{
Label: "linodego-vpc-test-" + getUniqueText(),
Expand Down