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: Update VPCSubnet linodes field to reflect API changes #414

Merged

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Oct 26, 2023

📝 Description

This PR updates the VPCSubnet.Linodes field to reflect the new structure returned from the API. This structure now includes an interfaces field that contains related Linode interfaces for this VPC.

Additionally, this change adds a VPC test resource modifier to keep regions consistent in E2E tests.

✔️ How to Test

E2E Testing:

make ARGS="-run TestVPC_Subnet_WithInstance" fixtures

Manual Testing:

Inside of a linodego sandbox environment (dx-devenv), write and run the following example in main.go:

package main

import (
	"context"
	"fmt"
	"github.com/linode/linodego"
	"os"
)

func main() {
	client := linodego.NewClient(nil)
	client.SetToken(os.Getenv("LINODE_TOKEN"))

	vpc, _ := client.CreateVPC(context.Background(), linodego.VPCCreateOptions{
		Label:  "foobar",
		Region: "us-east",
		Subnets: []linodego.VPCSubnetCreateOptions{
			{
				Label: "foobar",
			},
		},
	})

	inst, _ := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{
		Label:    "foobar",
		Type:     "g6-nanode-1",
		Region:   "us-east",
		Image:    "linode/alpine3.18",
		RootPass: "v3ryl3g1tp4ssw0rd!!!!!!!!",
		Interfaces: []linodego.InstanceConfigInterfaceCreateOptions{
			{
				Purpose: linodego.InterfacePurposePublic,
			},
			{
				Purpose:  linodego.InterfacePurposeVPC,
				SubnetID: &vpc.Subnets[0].ID,
			},
		},
	})

	subnet, _ := client.GetVPCSubnet(context.Background(), vpc.ID, vpc.Subnets[0].ID)

	fmt.Println(subnet.Linodes)
}

Copy link
Contributor

@amisiorek-akamai amisiorek-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests work on my end! One small thing, maybe we should change "us-east" to either "us-mia" or "us-lax" in TestVPC_Subnet_WithInstance if it's been moved to prod? I don't think it's available in us-east yet

@lgarber-akamai
Copy link
Contributor Author

lgarber-akamai commented Oct 31, 2023

Tests work on my end! One small thing, maybe we should change "us-east" to either "us-mia" or "us-lax" in TestVPC_Subnet_WithInstance if it's been moved to prod? I don't think it's available in us-east yet

@amisiorek-akamai Nice catch! I'll update the test case to reflect VPC availability in prod

Copy link
Contributor

@jriddle-linode jriddle-linode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zliang-akamai zliang-akamai merged commit 9b51629 into linode:proj/vpc Nov 2, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants