support volumes created before name rules changed (#404)

* support volumes created before name rules changed

In 2019, DigitalOcean accepted volumes created with underscores in the name. In 2020, this is no longer the case but it leaves us without a way to work with volumes created in the old rules.

* Add comment on why regexp does not match message.

Co-authored-by: Andrew Starr-Bochicchio <a.starr.b@gmail.com>
This commit is contained in:
Brian Hicks 2020-03-31 08:45:07 -05:00 committed by GitHub
parent 12af297769
commit d5a228360e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -34,10 +34,12 @@ func resourceDigitalOceanVolume() *schema.Resource {
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9\-]+$`), "Names must be lowercase and be composed only of numbers, letters and \"-\"."),
Type: schema.TypeString,
Required: true,
ForceNew: true,
// Underscores (_) allowed for backwards compatibility.
// See: https://github.com/terraform-providers/terraform-provider-digitalocean/pull/404
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9\-_]+$`), "Names must be lowercase and be composed only of numbers, letters and \"-\"."),
},
"urn": {
Type: schema.TypeString,