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

azurerm_postgres_database allow -s in database collation #4866

Merged
merged 4 commits into from
Nov 18, 2019
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
4 changes: 2 additions & 2 deletions azurerm/helpers/validate/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ func DatabaseCollation(i interface{}, k string) (warnings []string, errors []err
return
}

matched, _ := regexp.MatchString(`^[A-Za-z0-9_. ]+$`, v)
matched, _ := regexp.MatchString(`^[-A-Za-z0-9_. ]+$`, v)

if !matched {
errors = append(errors, fmt.Errorf("%s contains invalid characters, only underscores are supported, got %s", k, v))
errors = append(errors, fmt.Errorf("%s contains invalid characters, only alphanumeric, underscore, space or hyphen characters are supported, got %s", k, v))
return
}

Expand Down
6 changes: 5 additions & 1 deletion azurerm/helpers/validate/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ func TestDatabaseCollation(t *testing.T) {
Errors int
}{
{
Value: "en-US",
Value: "en@US",
Errors: 1,
},
{
Value: "en-US",
Errors: 0,
},
{
Value: "en_US",
Errors: 0,
Expand Down
7 changes: 1 addition & 6 deletions azurerm/resource_arm_postgresql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
Expand Down Expand Up @@ -152,11 +151,7 @@ func resourceArmPostgreSQLDatabaseRead(d *schema.ResourceData, meta interface{})

if props := resp.DatabaseProperties; props != nil {
d.Set("charset", props.Charset)

if collation := props.Collation; collation != nil {
v := strings.Replace(*collation, "-", "_", -1)
d.Set("collation", v)
}
d.Set("collation", props.Collation)
}

return nil
Expand Down