Merge pull request #7786 from zqfan/tencent-rm-img-name-limit

remove image name check in tencentcloud builder
This commit is contained in:
Megan Marsh 2019-06-26 14:22:50 -07:00 committed by GitHub
commit 350894200e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -2,7 +2,6 @@ package cvm
import (
"fmt"
"regexp"
"github.com/hashicorp/packer/template/interpolate"
)
@ -26,11 +25,6 @@ func (cf *TencentCloudImageConfig) Prepare(ctx *interpolate.Context) []error {
errs = append(errs, fmt.Errorf("image_name must be set"))
} else if len(cf.ImageName) > 20 {
errs = append(errs, fmt.Errorf("image_num length should not exceed 20 characters"))
} else {
regex := regexp.MustCompile("^[0-9a-zA-Z\\-]+$")
if !regex.MatchString(cf.ImageName) {
errs = append(errs, fmt.Errorf("image_name can only be composed of letters, numbers and minus sign"))
}
}
if len(cf.ImageDescription) > 60 {

View File

@ -11,9 +11,9 @@ func TestTencentCloudImageConfig_Prepare(t *testing.T) {
t.Fatalf("shouldn't have err: %v", err)
}
cf.ImageName = "foo:"
if err := cf.Prepare(nil); err == nil {
t.Fatal("should have error")
cf.ImageName = "foo.:"
if err := cf.Prepare(nil); err != nil {
t.Fatal("shouldn't have error")
}
cf.ImageName = "foo"