Merge pull request #4768 from hashicorp/validaminame
builder/amazon: numbers are valid in ami name
This commit is contained in:
commit
f71d2c14c0
|
@ -73,9 +73,12 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
errs = append(errs, fmt.Errorf("AMIName must be between 3 and 128 characters long"))
|
||||
}
|
||||
|
||||
amiNameRe := regexp.MustCompile(`^[a-zA-Z().\-/_]+$`)
|
||||
amiNameRe := regexp.MustCompile(`^[0-9a-zA-Z().\-/_]+$`)
|
||||
if !amiNameRe.MatchString(c.AMIName) {
|
||||
errs = append(errs, fmt.Errorf("AMIName should only contain letters, numbers, '(', ')', '.', '-', '/' and '_'"))
|
||||
errs = append(errs, fmt.Errorf("AMIName should only contain letters,"+
|
||||
" numbers, '(', ')', '.', '-', '/' and '_'. You can use the "+
|
||||
"`clean_ami_name` template filter to automatically clean your ami "+
|
||||
"name."))
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -102,4 +102,9 @@ func TestAMINameValidation(t *testing.T) {
|
|||
t.Fatal("expected 'foobar' to be a valid ami name")
|
||||
}
|
||||
|
||||
c.AMIName = `xyz-base-2017-04-05-1934`
|
||||
if err := c.Prepare(nil); err != nil {
|
||||
t.Fatalf("expected `xyz-base-2017-04-05-1934` to pass validation.")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue