Skip to content
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
2 changes: 1 addition & 1 deletion mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ type MySQLUpdateOptions struct {
ClusterSize int `json:"cluster_size,omitempty"`
Version string `json:"version,omitempty"`
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
PrivateNetwork **DatabasePrivateNetwork `json:"private_network,omitempty"`
}

// MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database
Expand Down
7 changes: 7 additions & 0 deletions test/unit/fixtures/vpc_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
]
}
],
"databases": [
{
"id": 123,
"ipv4_range": "10.0.0.4/32",
"ipv6_range": null
}
],
"updated": "2023-09-11T00:00:00"
}
],
Expand Down
7 changes: 7 additions & 0 deletions test/unit/fixtures/vpc_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
]
}
],
"databases": [
{
"id": 123,
"ipv4_range": "10.0.0.4/32",
"ipv6_range": null
}
],
"updated": "2023-09-11T00:00:00"
}
],
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/vpc_subnet_create.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
],
"linodes": [],
"databases": [],
"created": "2025-01-01T12:00:00",
"updated": "2025-01-01T12:00:00"
}
7 changes: 7 additions & 0 deletions test/unit/fixtures/vpc_subnet_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
]
}
],
"databases": [
{
"id": 123,
"ipv4_range": "10.0.0.4/32",
"ipv6_range": null
}
],
"created": "2025-01-01T10:00:00",
"updated": "2025-01-02T10:00:00"
}
10 changes: 9 additions & 1 deletion test/unit/fixtures/vpc_subnets_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@
}
]
}
]
],
"databases": []
},
{
"id": 124,
"label": "Subnet B",
"ipv4": "192.168.4.0/24",
"ipv6": [],
"linodes": [],
"databases": [
{
"id": 123,
"ipv4_range": "10.0.0.4/32",
"ipv6_range": null
}
],
"updated": "2023-09-11T00:00:00"
}
],
Expand Down
12 changes: 7 additions & 5 deletions test/unit/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ func TestDatabaseMySQL_Update(t *testing.T) {
ConnectTimeout: linodego.Pointer(20),
},
},
PrivateNetwork: &linodego.DatabasePrivateNetwork{
VPCID: 1234,
SubnetID: 5678,
PublicAccess: true,
},
PrivateNetwork: linodego.DoublePointer(
linodego.DatabasePrivateNetwork{
VPCID: 1234,
SubnetID: 5678,
PublicAccess: true,
},
),
}

base.MockPut("databases/mysql/instances/123", fixtureData)
Expand Down
8 changes: 8 additions & 0 deletions test/unit/vpc_subnets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func TestVPCSubnet_Get(t *testing.T) {
assert.Equal(t, 422, subnet.Linodes[0].Interfaces[1].ID)
assert.False(t, subnet.Linodes[0].Interfaces[1].Active, "Expected interface to be inactive")
assert.Nil(t, subnet.Linodes[0].Interfaces[1].ConfigID)

assert.Equal(t, 123, subnet.Databases[0].ID)
assert.Equal(t, "10.0.0.4/32", *subnet.Databases[0].IPv4Range)
assert.Nil(t, subnet.Databases[0].IPv6Range)
}

func TestVPCSubnets_List(t *testing.T) {
Expand Down Expand Up @@ -112,6 +116,10 @@ func TestVPCSubnets_List(t *testing.T) {
assert.Equal(t, "192.168.4.0/24", subnet.IPv4, "Expected second subnet IPv4 to match")
assert.Empty(t, subnet.IPv6, 0, "Expected second subnet to not support IPv6")
assert.Empty(t, subnet.Linodes, 0, "Expected second subnet to not have Linodes")

assert.Equal(t, 123, subnet.Databases[0].ID)
assert.Equal(t, "10.0.0.4/32", *subnet.Databases[0].IPv4Range)
assert.Nil(t, subnet.Databases[0].IPv6Range)
}

func TestVPCSubnet_Update(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions test/unit/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func TestVPC_Get(t *testing.T) {
assert.Equal(t, true, vpc.Subnets[0].Linodes[0].Interfaces[0].Active)
assert.Equal(t, 4567, *vpc.Subnets[0].Linodes[0].Interfaces[0].ConfigID)
assert.Equal(t, 421, vpc.Subnets[0].Linodes[0].Interfaces[0].ID)

assert.Equal(t, 123, vpc.Subnets[0].Databases[0].ID)
assert.Equal(t, "10.0.0.4/32", *vpc.Subnets[0].Databases[0].IPv4Range)
assert.Nil(t, vpc.Subnets[0].Databases[0].IPv6Range)
}

func TestVPC_List(t *testing.T) {
Expand Down Expand Up @@ -127,6 +131,10 @@ func TestVPC_List(t *testing.T) {
assert.Equal(t, true, vpc.Subnets[0].Linodes[0].Interfaces[0].Active)
assert.Equal(t, 4567, *vpc.Subnets[0].Linodes[0].Interfaces[0].ConfigID)
assert.Equal(t, 421, vpc.Subnets[0].Linodes[0].Interfaces[0].ID)

assert.Equal(t, 123, vpc.Subnets[0].Databases[0].ID)
assert.Equal(t, "10.0.0.4/32", *vpc.Subnets[0].Databases[0].IPv4Range)
assert.Nil(t, vpc.Subnets[0].Databases[0].IPv6Range)
}

func TestVPC_Update(t *testing.T) {
Expand Down
15 changes: 12 additions & 3 deletions vpc_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ type VPCSubnetLinode struct {
Interfaces []VPCSubnetLinodeInterface `json:"interfaces"`
}

// VPCSubnetDatabase represents a Linode currently assigned to a VPC subnet.
type VPCSubnetDatabase struct {
ID int `json:"id"`
IPv4Range *string `json:"ipv4_range"`
IPv6Range *string `json:"ipv6_range"`
}

type VPCSubnet struct {
ID int `json:"id"`
Label string `json:"label"`
Expand All @@ -30,9 +37,11 @@ type VPCSubnet struct {
// NOTE: IPv6 VPCs may not currently be available to all users.
IPv6 []VPCIPv6Range `json:"ipv6"`

Linodes []VPCSubnetLinode `json:"linodes"`
Created *time.Time `json:"-"`
Updated *time.Time `json:"-"`
Linodes []VPCSubnetLinode `json:"linodes"`
Databases []VPCSubnetDatabase `json:"databases"`

Created *time.Time `json:"-"`
Updated *time.Time `json:"-"`
}

type VPCSubnetCreateOptions struct {
Expand Down