Skip to content

Commit

Permalink
Update charset and collation of azurerm_postgresql_flexible_server_da…
Browse files Browse the repository at this point in the history
…tabase to optional (#13110)
  • Loading branch information
Neil Ye authored Aug 26, 2021
1 parent 36ce1b7 commit 02274a1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ func resourcePostgresqlFlexibleServerDatabase() *pluginsdk.Resource {

"charset": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
ForceNew: true,
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validate.DatabaseCharset,
Default: "UTF8",
},

"collation": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validate.DatabaseCollation,
Default: "en_US.utf8",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ func TestAccPostgresqlFlexibleServerDatabase_charsetLowercase(t *testing.T) {
})
}

func TestAccPostgresqlFlexibleServerDatabase_withoutCharsetAndCollation(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_postgresql_flexible_server_database", "test")
r := PostgresqlFlexibleServerDatabaseResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.withoutCharsetAndCollation(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (PostgresqlFlexibleServerDatabaseResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.FlexibleServerDatabaseID(state.ID)
if err != nil {
Expand Down Expand Up @@ -114,3 +128,14 @@ resource "azurerm_postgresql_flexible_server_database" "test" {
}
`, PostgresqlFlexibleServerResource{}.basic(data), data.RandomInteger)
}

func (PostgresqlFlexibleServerDatabaseResource) withoutCharsetAndCollation(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_postgresql_flexible_server_database" "test" {
name = "acctest-fsd-%d"
server_id = azurerm_postgresql_flexible_server.test.id
}
`, PostgresqlFlexibleServerResource{}.basic(data), data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ The following arguments are supported:

* `server_id` - (Required) The ID of the Azure PostgreSQL Flexible Server from which to create this PostgreSQL Flexible Server Database. Changing this forces a new Azure PostgreSQL Flexible Server Database to be created.

* `charset` - (Required) Specifies the Charset for the Azure PostgreSQL Flexible Server Database, which needs [to be a valid PostgreSQL Charset](https://www.postgresql.org/docs/current/static/multibyte.html). Changing this forces a new Azure PostgreSQL Flexible Server Database to be created.
* `charset` - (Optional) Specifies the Charset for the Azure PostgreSQL Flexible Server Database, which needs [to be a valid PostgreSQL Charset](https://www.postgresql.org/docs/current/static/multibyte.html). Defaults to `UTF8`. Changing this forces a new Azure PostgreSQL Flexible Server Database to be created.


* `collation` - (Required) Specifies the Collation for the Azure PostgreSQL Flexible Server Database, which needs [to be a valid PostgreSQL Collation](https://www.postgresql.org/docs/current/static/collation.html). Changing this forces a new Azure PostgreSQL Flexible Server Database to be created.
* `collation` - (Optional) Specifies the Collation for the Azure PostgreSQL Flexible Server Database, which needs [to be a valid PostgreSQL Collation](https://www.postgresql.org/docs/current/static/collation.html). Defaults to `en_US.utf8`. Changing this forces a new Azure PostgreSQL Flexible Server Database to be created.

## Attributes Reference

Expand Down

0 comments on commit 02274a1

Please sign in to comment.