Change the default for `valid_until` to `infinity` to match the default.

This commit is contained in:
Sean Chittenden 2016-12-12 01:18:13 -08:00
parent e9dc92c18d
commit e36827c5fe
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
2 changed files with 5 additions and 5 deletions

View File

@ -65,10 +65,10 @@ func resourcePostgreSQLRole() *schema.Resource {
Default: true, Default: true,
Description: "Control whether the password is stored encrypted in the system catalogs", Description: "Control whether the password is stored encrypted in the system catalogs",
}, },
roleValidUntilAttr: { roleValidUntilAttr: {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Default: "infinity",
Description: "Sets a date and time after which the role's password is no longer valid", Description: "Sets a date and time after which the role's password is no longer valid",
}, },
roleConnLimitAttr: { roleConnLimitAttr: {
@ -188,8 +188,8 @@ func resourcePostgreSQLRoleCreate(d *schema.ResourceData, meta interface{}) erro
} }
case opt.hclKey == roleValidUntilAttr: case opt.hclKey == roleValidUntilAttr:
switch { switch {
case v.(string) == "", strings.ToUpper(v.(string)) == "NULL": case v.(string) == "", strings.ToLower(v.(string)) == "infinity":
createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, "'infinity'")) createOpts = append(createOpts, fmt.Sprintf("%s '%s'", opt.sqlKey, "infinity"))
default: default:
createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, pq.QuoteIdentifier(val))) createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, pq.QuoteIdentifier(val)))
} }

View File

@ -46,7 +46,7 @@ func TestAccPostgresqlRole_Basic(t *testing.T) {
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"postgresql_role.role_with_defaults", "password", ""), "postgresql_role.role_with_defaults", "password", ""),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"postgresql_role.role_with_defaults", "valid_until", "NULL"), "postgresql_role.role_with_defaults", "valid_until", "infinity"),
), ),
}, },
}, },
@ -165,6 +165,6 @@ resource "postgresql_role" "role_with_defaults" {
connection_limit = -1 connection_limit = -1
encrypted_password = true encrypted_password = true
password = "" password = ""
valid_until = "NULL" valid_until = "infinity"
} }
` `