Factor out the validate function for connection limits
This commit is contained in:
parent
02dea2edd9
commit
242405bdf1
|
@ -56,14 +56,9 @@ func resourcePostgreSQLDatabase() *schema.Resource {
|
||||||
"connection_limit": {
|
"connection_limit": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "How many concurrent connections can be made to this database.",
|
Computed: true,
|
||||||
ValidateFunc: func(v interface{}, key string) (warnings []string, errors []error) {
|
Description: "How many concurrent connections can be made to this database",
|
||||||
value := v.(int)
|
ValidateFunc: validateConnLimit,
|
||||||
if value < -1 {
|
|
||||||
errors = append(errors, fmt.Errorf("%d can not be less than -1", key))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"allow_connections": {
|
"allow_connections": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
|
@ -81,6 +76,14 @@ func resourcePostgreSQLDatabase() *schema.Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validateConnLimit(v interface{}, key string) (warnings []string, errors []error) {
|
||||||
|
value := v.(int)
|
||||||
|
if value < -1 {
|
||||||
|
errors = append(errors, fmt.Errorf("%d can not be less than -1", key))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func resourcePostgreSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourcePostgreSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*Client)
|
client := meta.(*Client)
|
||||||
conn, err := client.Connect()
|
conn, err := client.Connect()
|
||||||
|
|
Loading…
Reference in New Issue