Skip to content

Commit 2129356

Browse files
committed
Add version parameter for PostgreSQL
1 parent 0f24ff6 commit 2129356

File tree

7 files changed

+20
-0
lines changed

7 files changed

+20
-0
lines changed

config/ubicloud_openapi.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ paths:
533533
storage_size:
534534
type: integer
535535
description: Requested storage size in GiB
536+
version:
537+
type: string
538+
description: Requested Postgres version
536539
required:
537540
- size
538541
responses:
@@ -1069,6 +1072,9 @@ components:
10691072
ha_type:
10701073
type: string
10711074
description: High availability type
1075+
version:
1076+
type: string
1077+
description: Requested Postgres version
10721078
PostgresDetailed:
10731079
type: object
10741080
properties:
@@ -1093,6 +1099,9 @@ components:
10931099
ha_type:
10941100
type: string
10951101
description: High availability type
1102+
version:
1103+
type: string
1104+
description: Requested Postgres version
10961105
connection_string:
10971106
type: string
10981107
description: Connection string to the Postgres database

docs/data-sources/postgres.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ output "example_postgres" {
5656
- `primary` (Boolean) Is the database primary
5757
- `state` (String) State of the Postgres database
5858
- `storage_size_gib` (Number) Storage size in GiB
59+
- `version` (String) Requested Postgres version
5960
- `vm_size` (String) Size of the underlying VM
6061

6162
<a id="nestedatt--firewall_rules"></a>

docs/resources/postgres.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ resource "ubicloud_postgres" "example" {
4848

4949
- `ha_type` (String) High availability type
5050
- `storage_size` (Number) Requested storage size in GiB
51+
- `version` (String) Requested Postgres version
5152

5253
### Read-Only
5354

internal/provider/postgres_datasource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func setPostgresStateDatasource(ctx context.Context, postgresd *ubicloud_client.
100100
assignInt(postgresd.StorageSizeGib, &state.StorageSizeGib)
101101
assignBool(postgresd.Primary, &state.Primary)
102102
assignStr(postgresd.HaType, &state.HaType)
103+
assignStr(postgresd.Version, &state.Version)
103104
assignStr(postgresd.ConnectionString, &state.ConnectionString)
104105
assignStr(postgresd.EarliestRestoreTime, &state.EarliestRestoreTime)
105106
assignStr(postgresd.LatestRestoreTime, &state.LatestRestoreTime)

internal/provider/postgres_datasource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestAccPostgresDataSource(t *testing.T) {
2121
location = "%s"
2222
name = "%s"
2323
size = "standard-2"
24+
version = "17"
2425
}
2526
2627
data "ubicloud_postgres" "testacc" {
@@ -35,6 +36,7 @@ func TestAccPostgresDataSource(t *testing.T) {
3536
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "name", resName),
3637
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "vm_size", "standard-2"),
3738
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "ha_type", "none"),
39+
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "version", "17"),
3840
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "primary", "true"),
3941
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "firewall_rules.#", "1"),
4042
resource.TestCheckResourceAttr("data.ubicloud_postgres.testacc", "firewall_rules.0.cidr", "0.0.0.0/0"),

internal/provider/postgres_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func (r *postgresResource) Create(ctx context.Context, req resource.CreateReques
6969
if state.HaType.ValueString() != "" {
7070
body.HaType = state.HaType.ValueStringPointer()
7171
}
72+
if state.Version.ValueString() != "" {
73+
body.Version = state.Version.ValueStringPointer()
74+
}
7275
if state.StorageSize.ValueInt64() != 0 {
7376
storageSize := int(state.StorageSize.ValueInt64())
7477
body.StorageSize = &storageSize
@@ -197,6 +200,7 @@ func setPostgresStateResource(ctx context.Context, postgresd *ubicloud_client.Po
197200
assignInt(postgresd.StorageSizeGib, &state.StorageSizeGib)
198201
assignBool(postgresd.Primary, &state.Primary)
199202
assignStr(postgresd.HaType, &state.HaType)
203+
assignStr(postgresd.Version, &state.Version)
200204

201205
firewallRulesListValue, diags := GetPostgresFirewallRulesState(ctx, postgresd.FirewallRules)
202206
if diags.HasError() {

internal/provider/postgres_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestAccPostgresResource(t *testing.T) {
2222
location = "%s"
2323
name = "%s"
2424
size = "standard-2"
25+
version = "17"
2526
}`, GetTestAccProjectId(), GetTestAccLocation(), resName),
2627
Check: resource.ComposeAggregateTestCheckFunc(
2728
resource.TestCheckResourceAttrSet("ubicloud_postgres.testacc", "id"),
@@ -30,6 +31,7 @@ func TestAccPostgresResource(t *testing.T) {
3031
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "name", resName),
3132
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "vm_size", "standard-2"),
3233
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "ha_type", "none"),
34+
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "version", "17"),
3335
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "primary", "true"),
3436
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "firewall_rules.#", "1"),
3537
resource.TestCheckResourceAttr("ubicloud_postgres.testacc", "firewall_rules.0.cidr", "0.0.0.0/0"),

0 commit comments

Comments
 (0)