Validate connection pool name (#403)

* Validate length of database connection pool name

DO currently returns a 500 if the database connection pool name is longer than 60 characters, and their
documentation states that it should be between 3 and 63 characters long.

* Sort imports

* Fix typo
This commit is contained in:
Tommy Brunn 2020-03-23 15:50:32 +01:00 committed by GitHub
parent 2300b94e63
commit 12af297769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -32,7 +32,7 @@ func resourceDigitalOceanDatabaseConnectionPool() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.NoZeroValues,
ValidateFunc: validation.StringLenBetween(3, 63),
},
"user": {

View File

@ -3,11 +3,12 @@ package digitalocean
import (
"context"
"fmt"
"log"
"strings"
"github.com/digitalocean/godo"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
"strings"
)
func resourceDigitalOceanProject() *schema.Resource {
@ -34,7 +35,7 @@ func resourceDigitalOceanProject() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "the descirption of the project",
Description: "the description of the project",
ValidateFunc: validation.StringLenBetween(0, 255),
},
"purpose": {