From 20315155a91e5897c0e5aaa30c2789ba7b42a6db Mon Sep 17 00:00:00 2001 From: ZhiQiang Fan Date: Sun, 23 Jun 2019 20:32:13 +0800 Subject: [PATCH] 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. --- builder/tencentcloud/cvm/image_config.go | 6 ------ builder/tencentcloud/cvm/image_config_test.go | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/builder/tencentcloud/cvm/image_config.go b/builder/tencentcloud/cvm/image_config.go index c0e9386d8..5f666b74e 100644 --- a/builder/tencentcloud/cvm/image_config.go +++ b/builder/tencentcloud/cvm/image_config.go @@ -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 { diff --git a/builder/tencentcloud/cvm/image_config_test.go b/builder/tencentcloud/cvm/image_config_test.go index a6e441fc3..53f9240b7 100644 --- a/builder/tencentcloud/cvm/image_config_test.go +++ b/builder/tencentcloud/cvm/image_config_test.go @@ -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"