Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update charset and collation of azurerm_postgresql_flexible_server_database to optional #13110

Merged
merged 1 commit into from
Aug 26, 2021
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
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