builder/tencentcloud: Correct the image name length validation, the max length of image name is 60 (#8536)
This commit is contained in:
parent
3c5ce79c2f
commit
c3c2622204
|
@ -4,13 +4,14 @@ package cvm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TencentCloudImageConfig struct {
|
type TencentCloudImageConfig struct {
|
||||||
// The name you want to create your customize image,
|
// 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.
|
// or minus sign.
|
||||||
ImageName string `mapstructure:"image_name" required:"true"`
|
ImageName string `mapstructure:"image_name" required:"true"`
|
||||||
// Image description.
|
// Image description.
|
||||||
|
@ -40,11 +41,11 @@ func (cf *TencentCloudImageConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
cf.ForcePoweroff = true
|
cf.ForcePoweroff = true
|
||||||
if cf.ImageName == "" {
|
if cf.ImageName == "" {
|
||||||
errs = append(errs, fmt.Errorf("image_name must be specified"))
|
errs = append(errs, fmt.Errorf("image_name must be specified"))
|
||||||
} else if len(cf.ImageName) > 20 {
|
} else if utf8.RuneCountInString(cf.ImageName) > 60 {
|
||||||
errs = append(errs, fmt.Errorf("image_name length should not exceed 20 characters"))
|
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"))
|
errs = append(errs, fmt.Errorf("image_description length should not exceed 60 characters"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ a [communicator](/docs/templates/communicator.html) can be configured for this b
|
||||||
your customized image from.
|
your customized image from.
|
||||||
|
|
||||||
- `image_name` (string) - The name you want to create your customize image,
|
- `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.
|
or minus sign.
|
||||||
|
|
||||||
### Optional:
|
### Optional:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- Code generated from the comments of the TencentCloudImageConfig struct in builder/tencentcloud/cvm/image_config.go; DO NOT EDIT MANUALLY -->
|
<!-- 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,
|
- `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.
|
or minus sign.
|
||||||
|
|
Loading…
Reference in New Issue