builder/tencentcloud: Correct the image name length validation, the max length of image name is 60 (#8536)

This commit is contained in:
Shengyu Liu 2020-01-08 19:05:37 +08:00 committed by Adrien Delorme
parent 3c5ce79c2f
commit c3c2622204
3 changed files with 7 additions and 6 deletions

View File

@ -4,13 +4,14 @@ package cvm
import (
"fmt"
"unicode/utf8"
"github.com/hashicorp/packer/template/interpolate"
)
type TencentCloudImageConfig struct {
// The name you want to create your customize image,
// it should be composed of no more than 20 characters, of letters, numbers
// it should be composed of no more than 60 characters, of letters, numbers
// or minus sign.
ImageName string `mapstructure:"image_name" required:"true"`
// Image description.
@ -40,11 +41,11 @@ func (cf *TencentCloudImageConfig) Prepare(ctx *interpolate.Context) []error {
cf.ForcePoweroff = true
if cf.ImageName == "" {
errs = append(errs, fmt.Errorf("image_name must be specified"))
} else if len(cf.ImageName) > 20 {
errs = append(errs, fmt.Errorf("image_name length should not exceed 20 characters"))
} else if utf8.RuneCountInString(cf.ImageName) > 60 {
errs = append(errs, fmt.Errorf("image_name length should not exceed 60 characters"))
}
if len(cf.ImageDescription) > 60 {
if utf8.RuneCountInString(cf.ImageDescription) > 60 {
errs = append(errs, fmt.Errorf("image_description length should not exceed 60 characters"))
}

View File

@ -44,7 +44,7 @@ a [communicator](/docs/templates/communicator.html) can be configured for this b
your customized image from.
- `image_name` (string) - The name you want to create your customize image,
it should be composed of no more than 20 characters, of letters, numbers
it should be composed of no more than 60 characters, of letters, numbers
or minus sign.
### Optional:

View File

@ -1,6 +1,6 @@
<!-- Code generated from the comments of the TencentCloudImageConfig struct in builder/tencentcloud/cvm/image_config.go; DO NOT EDIT MANUALLY -->
- `image_name` (string) - The name you want to create your customize image,
it should be composed of no more than 20 characters, of letters, numbers
it should be composed of no more than 60 characters, of letters, numbers
or minus sign.