Skip to content

Commit c5b17e3

Browse files
Merge branch 'proj/vpc-linodes-enhanced-interfaces' into zhiwei/firewall-template
2 parents 39bd7a7 + 245b2f0 commit c5b17e3

24 files changed

Lines changed: 382 additions & 240 deletions

account_settings.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import (
44
"context"
55
)
66

7+
type InterfacesForNewLinodes string
8+
9+
const (
10+
LegacyConfigOnly InterfacesForNewLinodes = "legacy_config_only"
11+
LegacyConfigDefaultButLinodeAllowed InterfacesForNewLinodes = "legacy_config_default_but_linode_allowed"
12+
LinodeDefaultButLegacyConfigAllowed InterfacesForNewLinodes = "linode_default_but_legacy_config_allowed"
13+
LinodeOnly InterfacesForNewLinodes = "linode_only"
14+
)
15+
716
// AccountSettings are the account wide flags or plans that effect new resources
817
type AccountSettings struct {
918
// The default backups enrollment status for all new Linodes for all users on the account. When enabled, backups are mandatory per instance.
@@ -20,19 +29,23 @@ type AccountSettings struct {
2029

2130
// A string like "disabled", "suspended", or "active" describing the status of this account’s Object Storage service enrollment.
2231
ObjectStorage *string `json:"object_storage"`
32+
33+
// NOTE: Interfaces for new linode setting may not currently be available to all users.
34+
// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
35+
InterfacesForNewLinodes InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
2336
}
2437

2538
// AccountSettingsUpdateOptions are the updateable account wide flags or plans that effect new resources.
2639
type AccountSettingsUpdateOptions struct {
2740
// The default backups enrollment status for all new Linodes for all users on the account. When enabled, backups are mandatory per instance.
2841
BackupsEnabled *bool `json:"backups_enabled,omitempty"`
2942

30-
// A plan name like "longview-3"..."longview-100", or a nil value for to cancel any existing subscription plan.
31-
// Deprecated: Use PUT /longview/plan instead to update the LongviewSubscription
32-
LongviewSubscription *string `json:"longview_subscription,omitempty"`
33-
3443
// The default network helper setting for all new Linodes and Linode Configs for all users on the account.
3544
NetworkHelper *bool `json:"network_helper,omitempty"`
45+
46+
// NOTE: Interfaces for new linode setting may not currently be available to all users.
47+
// A new configuration flag defines whether new Linodes can use Linode and/or legacy config interfaces.
48+
InterfacesForNewLinodes *InterfacesForNewLinodes `json:"interfaces_for_new_linodes"`
3649
}
3750

3851
// GetAccountSettings gets the account wide flags or plans that effect new resources

firewall_devices.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type FirewallDeviceType string
1515
const (
1616
FirewallDeviceLinode FirewallDeviceType = "linode"
1717
FirewallDeviceNodeBalancer FirewallDeviceType = "nodebalancer"
18+
FirewallDeviceInterface FirewallDeviceType = "interface"
1819
)
1920

2021
// FirewallDevice represents a device governed by a Firewall

firewalls.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Firewall struct {
3333
type DevicesCreationOptions struct {
3434
Linodes []int `json:"linodes,omitempty"`
3535
NodeBalancers []int `json:"nodebalancers,omitempty"`
36+
Interfaces []int `json:"interfaces,omitempty"`
3637
}
3738

3839
// FirewallCreateOptions fields are those accepted by CreateFirewall
@@ -50,6 +51,31 @@ type FirewallUpdateOptions struct {
5051
Tags *[]string `json:"tags,omitempty"`
5152
}
5253

54+
// FirewallSettings represents the default firewalls for Linodes,
55+
// Linode VPC and public interfaces, and NodeBalancers.
56+
type FirewallSettings struct {
57+
DefaultFirewallIDs DefaultFirewallIDs `json:"default_firewall_ids"`
58+
}
59+
60+
type DefaultFirewallIDs struct {
61+
Linode int `json:"linode"`
62+
NodeBalancer int `json:"nodebalancer"`
63+
PublicInterface int `json:"public_interface"`
64+
VPCInterface int `json:"vpc_interface"`
65+
}
66+
67+
// FirewallSettingsUpdateOptions is an options struct used when Updating FirewallSettings
68+
type FirewallSettingsUpdateOptions struct {
69+
DefaultFirewallIDs DefaultFirewallIDsOptions `json:"default_firewall_ids"`
70+
}
71+
72+
type DefaultFirewallIDsOptions struct {
73+
Linode *int `json:"linode,omitempty"`
74+
NodeBalancer *int `json:"nodebalancer,omitempty"`
75+
PublicInterface *int `json:"public_interface,omitempty"`
76+
VPCInterface *int `json:"vpc_interface,omitempty"`
77+
}
78+
5379
// GetUpdateOptions converts a Firewall to FirewallUpdateOptions for use in Client.UpdateFirewall.
5480
func (f *Firewall) GetUpdateOptions() FirewallUpdateOptions {
5581
return FirewallUpdateOptions{
@@ -107,3 +133,13 @@ func (c *Client) DeleteFirewall(ctx context.Context, firewallID int) error {
107133
e := formatAPIPath("networking/firewalls/%d", firewallID)
108134
return doDELETERequest(ctx, c, e)
109135
}
136+
137+
// GetFirewallSettings returns default firewalls for Linodes, Linode VPC and public interfaces, and NodeBalancers.
138+
func (c *Client) GetFirewallSettings(ctx context.Context) (*FirewallSettings, error) {
139+
return doGETRequest[FirewallSettings](ctx, c, "networking/firewalls/settings")
140+
}
141+
142+
// UpdateFirewallSettings updates the default firewalls for Linodes, Linode VPC and public interfaces, and NodeBalancers.
143+
func (c *Client) UpdateFirewallSettings(ctx context.Context, opts FirewallSettingsUpdateOptions) (*FirewallSettings, error) {
144+
return doPUTRequest[FirewallSettings](ctx, c, "networking/firewalls/settings", opts)
145+
}

go.work.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5
5656
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
5757
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
5858
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
59+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
5960
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
6061
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
6162
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
@@ -77,17 +78,16 @@ golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
7778
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
7879
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
7980
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
81+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
8082
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
8183
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
8284
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
83-
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
8485
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 h1:IRJeR9r1pYWsHKTRe/IInb7lYvbBVIqOgsX/u0mbOWY=
8586
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
8687
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 h1:zf5N6UOrA487eEFacMePxjXAJctxKmyjKUsjA11Uzuk=
8788
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
8889
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
8990
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
90-
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
9191
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
9292
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
9393
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=

instance_ips.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ type InstanceIPv4Response struct {
2121

2222
// InstanceIP represents an Instance IP with additional DNS and networking details
2323
type InstanceIP struct {
24-
Address string `json:"address"`
25-
Gateway string `json:"gateway"`
26-
SubnetMask string `json:"subnet_mask"`
27-
Prefix int `json:"prefix"`
28-
Type InstanceIPType `json:"type"`
29-
Public bool `json:"public"`
30-
RDNS string `json:"rdns"`
31-
LinodeID int `json:"linode_id"`
32-
Region string `json:"region"`
33-
VPCNAT1To1 *InstanceIPNAT1To1 `json:"vpc_nat_1_1"`
34-
Reserved bool `json:"reserved"`
24+
Address string `json:"address"`
25+
Gateway string `json:"gateway"`
26+
SubnetMask string `json:"subnet_mask"`
27+
Prefix int `json:"prefix"`
28+
Type InstanceIPType `json:"type"`
29+
Public bool `json:"public"`
30+
RDNS string `json:"rdns"`
31+
LinodeID int `json:"linode_id"`
32+
InterfaceID *int `json:"interface_id"`
33+
Region string `json:"region"`
34+
VPCNAT1To1 *InstanceIPNAT1To1 `json:"vpc_nat_1_1"`
35+
Reserved bool `json:"reserved"`
3536
}
3637

3738
// VPCIP represents a private IP address in a VPC subnet with additional networking details

regions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const (
2222
CapabilityEdgePlans string = "Edge Plans"
2323
CapabilityGPU string = "GPU Linodes"
2424
CapabilityKubernetesEnterprise string = "Kubernetes Enterprise"
25+
CapabilityLinodeInterfaces string = "Linode Interfaces"
2526
CapabilityLKE string = "Kubernetes"
2627
CapabilityLKEControlPlaneACL string = "LKE Network Access Control List (IP ACL)"
2728
CapabilityLinodes string = "Linodes"

test/integration/account_settings_test.go

Lines changed: 0 additions & 79 deletions
This file was deleted.

test/integration/fixtures/TestAccountSettings.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

test/unit/account_settings_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func TestAccountSettings_Get(t *testing.T) {
3131
assert.Nil(t, accountSettings.LongviewSubscription, "Expected 'longview_subscription' to be nil")
3232
assert.True(t, accountSettings.BackupsEnabled, "Expected 'backups_enabled' to be true")
3333
assert.Equal(t, "active", *accountSettings.ObjectStorage, "Expected 'object_storage' to be 'active'")
34+
assert.Equal(
35+
t, linodego.LegacyConfigDefaultButLinodeAllowed, accountSettings.InterfacesForNewLinodes,
36+
"Expected 'object_storage' to be 'active'",
37+
)
3438
}
3539

3640
func TestAccountSettings_Update(t *testing.T) {
@@ -41,9 +45,11 @@ func TestAccountSettings_Update(t *testing.T) {
4145
base.SetUp(t)
4246
defer base.TearDown(t)
4347

48+
i := linodego.LegacyConfigDefaultButLinodeAllowed
4449
requestData := linodego.AccountSettingsUpdateOptions{
45-
BackupsEnabled: Bool(true),
46-
NetworkHelper: Bool(true),
50+
BackupsEnabled: Bool(true),
51+
NetworkHelper: Bool(true),
52+
InterfacesForNewLinodes: &i,
4753
}
4854
base.MockPut("account/settings", fixtureData)
4955

@@ -55,4 +61,8 @@ func TestAccountSettings_Update(t *testing.T) {
5561
assert.Nil(t, accountSettings.LongviewSubscription, "Expected 'longview_subscription' to be nil")
5662
assert.True(t, accountSettings.BackupsEnabled, "Expected 'backups_enabled' to be true")
5763
assert.Equal(t, "active", *accountSettings.ObjectStorage, "Expected 'object_storage' to be 'active'")
64+
assert.Equal(
65+
t, linodego.LegacyConfigDefaultButLinodeAllowed, accountSettings.InterfacesForNewLinodes,
66+
"Expected 'object_storage' to be 'active'",
67+
)
5868
}

0 commit comments

Comments
 (0)