-
Notifications
You must be signed in to change notification settings - Fork 87
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
Nodebalancer VPC support #678
Open
komer3
wants to merge
16
commits into
linode:main
Choose a base branch
from
komer3:listnbvpc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5cd1e22
Adding the funcs for the List VPC and Get VPC for Nodebalancers endpo…
komer3 230f4dc
Adding test cases - they don't work until we update some nodebalance…
komer3 e075874
IPv6 can sometime be empty so adding omiempty here
komer3 94aa731
add vpcs config during nodebalancer create
rahulait 662422b
update node config as well
rahulait c42984f
Merge pull request #1 from rahulait/nb-vpc-updates
komer3 eff3930
add nb vpc test
rahulait 1f6cf9d
Adding records for fixtures
komer3 66f7ae7
add generated fixtures
rahulait 8bab48f
fix cleanup failures
rahulait 4729ea7
Update the fixture for nb vpc list and get
komer3 e46f739
Merge branch 'main' into listnbvpc
komer3 2d5a46d
fix formatting
rahulait 7b94319
Update nodebalancer_config_vpc.go
komer3 feb92c8
Fix naming
komer3 c3fe2ac
Adding disclaimer for letting users know this might not be available …
komer3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package linodego | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// NodeBalancerVPCConfig objects represent a VPC config for a NodeBalancer | ||
// s | ||
// NOTE: NodeBalancer VPC support may not currently be available to all users. | ||
type NodeBalancerVPCConfig struct { | ||
ID int `json:"id"` | ||
IPv4Range string `json:"ipv4_range"` | ||
IPv6Range string `json:"ipv6_range,omitempty"` | ||
NodeBalancerID int `json:"nodebalancer_id"` | ||
SubnetID int `json:"subnet_id"` | ||
VPCID int `json:"vpc_id"` | ||
} | ||
|
||
// ListNodeBalancerVPCConfigs lists NodeBalancer VPC configs | ||
func (c *Client) ListNodeBalancerVPCConfigs(ctx context.Context, nodebalancerID int, opts *ListOptions) ([]NodeBalancerVPCConfig, error) { | ||
return getPaginatedResults[NodeBalancerVPCConfig](ctx, c, formatAPIPath("nodebalancers/%d/vpcs", nodebalancerID), opts) | ||
} | ||
|
||
// GetNodeBalancerVPCConfig gets the NodeBalancer VPC config with the specified id | ||
func (c *Client) GetNodeBalancerVPCConfig(ctx context.Context, nodebalancerID int, vpcID int) (*NodeBalancerVPCConfig, error) { | ||
e := formatAPIPath("nodebalancers/%d/vpcs/%d", nodebalancerID, vpcID) | ||
return doGETRequest[NodeBalancerVPCConfig](ctx, c, e) | ||
} |
682 changes: 682 additions & 0 deletions
682
test/integration/fixtures/TestNodeBalancerVpcConfig_Get.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
619 changes: 619 additions & 0 deletions
619
test/integration/fixtures/TestNodeBalancerVpcConfig_List.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
546 changes: 546 additions & 0 deletions
546
test/integration/fixtures/TestNodeBalancer_With_VPC_Create.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNodeBalancerVPCConfig_List(t *testing.T) { | ||
client, nodebalancer, teardown, err := setupNodeBalancerWithVPC(t, "fixtures/TestNodeBalancerVpcConfig_List") | ||
if err != nil { | ||
t.Errorf("Error setting up nodebalancer: %s", err) | ||
} | ||
defer teardown() | ||
|
||
configs, err := client.ListNodeBalancerVPCConfigs(context.Background(), nodebalancer.ID, nil) | ||
if err != nil { | ||
t.Errorf("Error listing nodebalancer VPC configs: %s", err) | ||
} | ||
|
||
// We expect the list to be not empty and have at least one VPC config | ||
require.NotEmpty(t, configs) | ||
require.Len(t, configs, 1) | ||
} | ||
|
||
func TestNodeBalancerVPCConfig_Get(t *testing.T) { | ||
client, nodebalancer, teardown, err := setupNodeBalancerWithVPC(t, "fixtures/TestNodeBalancerVpcConfig_Get") | ||
if err != nil { | ||
t.Errorf("Error setting up nodebalancer: %s", err) | ||
} | ||
defer teardown() | ||
|
||
// Get the VPC config list for the nodebalancer (should only have one) | ||
configs, err := client.ListNodeBalancerVPCConfigs(context.Background(), nodebalancer.ID, nil) | ||
if err != nil { | ||
t.Errorf("Error listing nodebalancer VPC configs: %s", err) | ||
} | ||
require.NotEmpty(t, configs) | ||
require.Len(t, configs, 1) | ||
|
||
// Get the VPC config by ID | ||
config, err := client.GetNodeBalancerVPCConfig(context.Background(), nodebalancer.ID, configs[0].ID) | ||
if err != nil { | ||
t.Errorf("Error getting nodebalancer VPC config: %s", err) | ||
} | ||
require.NotNil(t, config) | ||
require.Equal(t, configs[0].ID, config.ID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add LA disclaimer to the NB VPC-related fields, structs, and methods? Something along the lines of:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ofc! Let me add this