Skip to content

Commit e7aca77

Browse files
Added support for VPC DBaaS Integration and corresponding unit tests (#763)
1 parent dc7858d commit e7aca77

14 files changed

+125
-22
lines changed

databases.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ type Database struct {
9595
Created *time.Time `json:"-"`
9696
Updated *time.Time `json:"-"`
9797
OldestRestoreTime *time.Time `json:"-"`
98+
99+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
98100
}
99101

100102
// DatabaseHost for Primary/Secondary of Database
@@ -103,6 +105,12 @@ type DatabaseHost struct {
103105
Secondary string `json:"secondary,omitempty"`
104106
}
105107

108+
type DatabasePrivateNetwork struct {
109+
VPCID int `json:"vpc_id"`
110+
SubnetID int `json:"subnet_id"`
111+
PublicAccess bool `json:"public_access"`
112+
}
113+
106114
// DatabaseEngine is information about Engines supported by Linode Managed Databases
107115
type DatabaseEngine struct {
108116
ID string `json:"id"`

mysql.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ type MySQLDatabase struct {
5151
TotalDiskSizeGB int `json:"total_disk_size_gb"`
5252
Port int `json:"port"`
5353

54-
EngineConfig MySQLDatabaseEngineConfig `json:"engine_config"`
54+
EngineConfig MySQLDatabaseEngineConfig `json:"engine_config"`
55+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
5556
}
5657

5758
type MySQLDatabaseEngineConfig struct {
@@ -410,19 +411,21 @@ type MySQLCreateOptions struct {
410411
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
411412
SSLConnection bool `json:"ssl_connection,omitempty"`
412413

413-
Fork *DatabaseFork `json:"fork,omitempty"`
414-
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
414+
Fork *DatabaseFork `json:"fork,omitempty"`
415+
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
416+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
415417
}
416418

417419
// MySQLUpdateOptions fields are used when altering the existing MySQL Database
418420
type MySQLUpdateOptions struct {
419-
Label string `json:"label,omitempty"`
420-
AllowList *[]string `json:"allow_list,omitempty"`
421-
Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"`
422-
Type string `json:"type,omitempty"`
423-
ClusterSize int `json:"cluster_size,omitempty"`
424-
Version string `json:"version,omitempty"`
425-
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
421+
Label string `json:"label,omitempty"`
422+
AllowList *[]string `json:"allow_list,omitempty"`
423+
Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"`
424+
Type string `json:"type,omitempty"`
425+
ClusterSize int `json:"cluster_size,omitempty"`
426+
Version string `json:"version,omitempty"`
427+
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
428+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
426429
}
427430

428431
// MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database

postgres.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type PostgresDatabase struct {
6969
UsedDiskSizeGB int `json:"used_disk_size_gb"`
7070
TotalDiskSizeGB int `json:"total_disk_size_gb"`
7171
EngineConfig PostgresDatabaseEngineConfig `json:"engine_config"`
72+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
7273
}
7374

7475
type PostgresDatabaseEngineConfig struct {
@@ -612,18 +613,20 @@ type PostgresCreateOptions struct {
612613

613614
Fork *DatabaseFork `json:"fork,omitempty"`
614615

615-
EngineConfig *PostgresDatabaseEngineConfig `json:"engine_config,omitempty"`
616+
EngineConfig *PostgresDatabaseEngineConfig `json:"engine_config,omitempty"`
617+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
616618
}
617619

618620
// PostgresUpdateOptions fields are used when altering the existing Postgres Database
619621
type PostgresUpdateOptions struct {
620-
Label string `json:"label,omitempty"`
621-
AllowList *[]string `json:"allow_list,omitempty"`
622-
Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"`
623-
Type string `json:"type,omitempty"`
624-
ClusterSize int `json:"cluster_size,omitempty"`
625-
Version string `json:"version,omitempty"`
626-
EngineConfig *PostgresDatabaseEngineConfig `json:"engine_config,omitempty"`
622+
Label string `json:"label,omitempty"`
623+
AllowList *[]string `json:"allow_list,omitempty"`
624+
Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"`
625+
Type string `json:"type,omitempty"`
626+
ClusterSize int `json:"cluster_size,omitempty"`
627+
Version string `json:"version,omitempty"`
628+
EngineConfig *PostgresDatabaseEngineConfig `json:"engine_config,omitempty"`
629+
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
627630
}
628631

629632
// PostgresDatabaseSSL is the SSL Certificate to access the Linode Managed Postgres Database

test/unit/fixtures/databases_list.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
"version": "8.0",
1111
"cluster_size": 3,
1212
"platform": "rdbms-default",
13-
"created": "2023-01-01T12:00:00"
14-
}
13+
"created": "2023-01-01T12:00:00",
14+
"private_network": {
15+
"vpc_id": 1234,
16+
"subnet_id": 5678,
17+
"public_access": true
18+
}
19+
}
1520
],
1621
"page": 1,
1722
"pages": 1,

test/unit/fixtures/mysql_database_create.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@
7070
"tmp_table_size": 16777216,
7171
"wait_timeout": 28800
7272
}
73+
},
74+
"private_network": {
75+
"vpc_id": 1234,
76+
"subnet_id": 5678,
77+
"public_access": true
7378
}
7479
}

test/unit/fixtures/mysql_database_get.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@
7070
"tmp_table_size": 16777216,
7171
"wait_timeout": 28800
7272
}
73+
},
74+
"private_network": {
75+
"vpc_id": 1234,
76+
"subnet_id": 5678,
77+
"public_access": true
7378
}
7479
}

test/unit/fixtures/mysql_database_update.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@
7070
"tmp_table_size": 16777216,
7171
"wait_timeout": 28800
7272
}
73+
},
74+
"private_network": {
75+
"vpc_id": 1234,
76+
"subnet_id": 5678,
77+
"public_access": true
7378
}
7479
}

test/unit/fixtures/mysql_databases_list.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@
4141
"pending": []
4242
},
4343
"used_disk_size_gb": 2,
44-
"version": "8.0.26"
44+
"version": "8.0.26",
45+
"private_network": {
46+
"vpc_id": 1234,
47+
"subnet_id": 5678,
48+
"public_access": true
49+
}
4550
}
4651
],
4752
"page": 1,

test/unit/fixtures/postgresql_database_create.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,10 @@
9090
},
9191
"shared_buffers_percentage": 41.5,
9292
"work_mem": 4
93+
},
94+
"private_network": {
95+
"vpc_id": 1234,
96+
"subnet_id": 5678,
97+
"public_access": true
9398
}
9499
}

test/unit/fixtures/postgresql_database_get.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,10 @@
9090
},
9191
"shared_buffers_percentage": 41.5,
9292
"work_mem": 4
93+
},
94+
"private_network": {
95+
"vpc_id": 1234,
96+
"subnet_id": 5678,
97+
"public_access": true
9398
}
9499
}

0 commit comments

Comments
 (0)