remove image name check in tencentcloud builder
Spinnaker uses packer to create images, but tencentcloud builder has name check to forbidden special characters such as dot(.) while it is absolutely valid in API side. This patch simply removes this limitation.
This commit is contained in:
parent
757bd4bed9
commit
20315155a9
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue