Merge pull request #5272 from hashicorp/phinze/resource-name-validation

terraform: upgrade resource name regexp failure to error
This commit is contained in:
Paul Hinze 2016-02-23 10:58:25 -06:00
commit 510025da19
2 changed files with 5 additions and 6 deletions

View File

@ -576,10 +576,10 @@ func TestContext2Validate_resourceNameSymbol(t *testing.T) {
}) })
w, e := c.Validate() w, e := c.Validate()
if len(w) == 0 { if len(w) > 0 {
t.Fatalf("bad: %#v", w) t.Fatalf("bad: %#v", w)
} }
if len(e) > 0 { if len(e) == 0 {
t.Fatalf("bad: %s", e) t.Fatalf("bad: %s", e)
} }
} }

View File

@ -119,11 +119,10 @@ func (n *EvalValidateResource) Eval(ctx EvalContext) (interface{}, error) {
// If the resouce name doesn't match the name regular // If the resouce name doesn't match the name regular
// expression, show a warning. // expression, show a warning.
if !config.NameRegexp.Match([]byte(n.ResourceName)) { if !config.NameRegexp.Match([]byte(n.ResourceName)) {
warns = append(warns, fmt.Sprintf( errs = append(errs, fmt.Errorf(
"%s: resource name can only contain letters, numbers, "+ "%s: resource name can only contain letters, numbers, "+
"dashes, and underscores.\n"+ "dashes, and underscores."+
"This will be an error in Terraform 0.4", n.ResourceName))
n.ResourceName))
} }
if len(warns) == 0 && len(errs) == 0 { if len(warns) == 0 && len(errs) == 0 {