Skip to content

Commit 38c5c32

Browse files
TPT-4329 Deprecate vpcs in favor of backend_vpcs
1 parent b352f40 commit 38c5c32

2 files changed

Lines changed: 56 additions & 7 deletions

File tree

nodebalancer.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ type NodeBalancerCreateOptions struct {
7676
// NOTE: ClientUDPSessThrottle may not currently be available to all users.
7777
ClientUDPSessThrottle *int `json:"client_udp_sess_throttle,omitempty"`
7878

79-
Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"`
80-
Tags []string `json:"tags"`
81-
FirewallID int `json:"firewall_id,omitempty"`
82-
Type NodeBalancerPlanType `json:"type,omitempty"`
83-
VPCs []NodeBalancerVPCOptions `json:"vpcs,omitempty"`
84-
FrontendVPCs []NodeBalancerFrontendVPCOptions `json:"frontend_vpcs,omitempty"`
85-
IPv4 *string `json:"ipv4,omitempty"`
79+
Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"`
80+
Tags []string `json:"tags"`
81+
FirewallID int `json:"firewall_id,omitempty"`
82+
Type NodeBalancerPlanType `json:"type,omitempty"`
83+
// Deprecated: `VPCs` is deprecated in favor of `BackendVPCs`.
84+
// This field may be removed in a later release.
85+
VPCs []NodeBalancerVPCOptions `json:"vpcs,omitempty"`
86+
BackendVPCs []NodeBalancerVPCOptions `json:"backend_vpcs,omitempty"`
87+
FrontendVPCs []NodeBalancerFrontendVPCOptions `json:"frontend_vpcs,omitempty"`
88+
IPv4 *string `json:"ipv4,omitempty"`
8689
}
8790

8891
// NodeBalancerUpdateOptions are the options permitted for UpdateNodeBalancer

test/unit/nodebalancer_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,49 @@ func TestNodeBalancer_Create_with_VPCs(t *testing.T) {
201201
assert.Equal(t, linodego.NodeBalancerVPCFrontendAddressTypeVPC, nb.FrontendAddressType)
202202
assert.Equal(t, 456, *nb.FrontendVPCSubnetID)
203203
}
204+
205+
func TestNodeBalancer_Create_with_BackendVPCs(t *testing.T) {
206+
// The response fixture is the same as the VPCs test since BackendVPCs and
207+
// VPCs are currently both accepted by the API.
208+
fixtureData, err := fixtures.GetFixture("nodebalancer_create_with_vpcs")
209+
assert.NoError(t, err)
210+
211+
var base ClientBaseCase
212+
base.SetUp(t)
213+
defer base.TearDown(t)
214+
215+
requestData := linodego.NodeBalancerCreateOptions{
216+
Label: String("Test NodeBalancer VPC"),
217+
Region: "us-east",
218+
Type: linodego.NBTypePremium40GB,
219+
BackendVPCs: []linodego.NodeBalancerVPCOptions{
220+
{
221+
SubnetID: 123,
222+
IPv4Range: "10.200.4.16/28",
223+
IPv6Range: "2600:3c01:e000:1::/64",
224+
IPv4RangeAutoAssign: false,
225+
},
226+
},
227+
FrontendVPCs: []linodego.NodeBalancerFrontendVPCOptions{
228+
{
229+
SubnetID: 456,
230+
IPv4Range: "10.200.5.16/28",
231+
IPv6Range: "2600:3c01:e000:101::/64",
232+
},
233+
},
234+
}
235+
236+
base.MockPost("nodebalancers", fixtureData)
237+
238+
nb, err := base.Client.CreateNodeBalancer(context.Background(), requestData)
239+
240+
assert.NoError(t, err)
241+
242+
assert.Equal(t, 12345, nb.ID)
243+
assert.Equal(t, "Test NodeBalancer VPC", *nb.Label)
244+
assert.Equal(t, "us-east", nb.Region)
245+
assert.Equal(t, linodego.NBTypePremium40GB, nb.Type)
246+
247+
assert.Equal(t, linodego.NodeBalancerVPCFrontendAddressTypeVPC, nb.FrontendAddressType)
248+
assert.Equal(t, 456, *nb.FrontendVPCSubnetID)
249+
}

0 commit comments

Comments
 (0)