diff --git a/builder/ucloud/common/consts.go b/builder/ucloud/common/consts.go index 87d32b11c..dd5049085 100644 --- a/builder/ucloud/common/consts.go +++ b/builder/ucloud/common/consts.go @@ -8,18 +8,20 @@ const ( ) const ( - OsTypeWindows = "Windows" - SecurityGroupNonWeb = "recommend non web" - InstanceStateRunning = "Running" - InstanceStateStopped = "Stopped" - BootDiskStateNormal = "Normal" + InstanceStateRunning = "Running" + InstanceStateStopped = "Stopped" + ImageStateAvailable = "Available" ImageStateUnavailable = "Unavailable" - IpTypePrivate = "Private" + + BootDiskStateNormal = "Normal" + OsTypeWindows = "Windows" + SecurityGroupNonWeb = "recommend non web" + IpTypePrivate = "Private" ) const ( - DefaultCreateImageTimeOut = 3600 + DefaultCreateImageTimeout = 3600 ) var BootDiskTypeMap = NewStringConverter(map[string]string{ diff --git a/builder/ucloud/common/errors.go b/builder/ucloud/common/errors.go index 0ed7efcf6..f1ad49eae 100644 --- a/builder/ucloud/common/errors.go +++ b/builder/ucloud/common/errors.go @@ -12,7 +12,7 @@ type ExpectedStateError struct { message string } -type NotCompleteError struct { +type NotCompletedError struct { message string } @@ -24,7 +24,7 @@ func (e *NotFoundError) Error() string { return e.message } -func (e *NotCompleteError) Error() string { +func (e *NotCompletedError) Error() string { return e.message } @@ -36,8 +36,8 @@ func NewExpectedStateError(product, id string) error { return &ExpectedStateError{fmt.Sprintf("the %s %s not be expected state", product, id)} } -func NewNotCompleteError(product string) error { - return &NotCompleteError{fmt.Sprintf("%s is not completed", product)} +func NewNotCompletedError(product string) error { + return &NotCompletedError{fmt.Sprintf("%s is not completed", product)} } func IsNotFoundError(err error) bool { @@ -55,7 +55,7 @@ func IsExpectedStateError(err error) bool { } func IsNotCompleteError(err error) bool { - if _, ok := err.(*NotCompleteError); ok { + if _, ok := err.(*NotCompletedError); ok { return true } return false diff --git a/builder/ucloud/common/image_config.go b/builder/ucloud/common/image_config.go index e469d67f2..e4b8a90c0 100644 --- a/builder/ucloud/common/image_config.go +++ b/builder/ucloud/common/image_config.go @@ -45,7 +45,7 @@ func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error { } if c.WaitImageReadyTimeout <= 0 { - c.WaitImageReadyTimeout = DefaultCreateImageTimeOut + c.WaitImageReadyTimeout = DefaultCreateImageTimeout } if len(errs) > 0 { diff --git a/builder/ucloud/uhost/step_copy_image.go b/builder/ucloud/uhost/step_copy_image.go index 1b8dba0bf..690b9deca 100644 --- a/builder/ucloud/uhost/step_copy_image.go +++ b/builder/ucloud/uhost/step_copy_image.go @@ -83,7 +83,7 @@ func (s *stepCopyUCloudImage) Run(ctx context.Context, state multistep.StateBag) } if len(expectedImages.GetAll()) != 0 { - return ucloudcommon.NewNotCompleteError("copying image") + return ucloudcommon.NewNotCompletedError("copying image") } return nil diff --git a/builder/ucloud/uhost/step_create_instance.go b/builder/ucloud/uhost/step_create_instance.go index fd35aaa64..3c60daef8 100644 --- a/builder/ucloud/uhost/step_create_instance.go +++ b/builder/ucloud/uhost/step_create_instance.go @@ -267,7 +267,7 @@ func (s *stepCreateInstance) buildCreateInstanceRequest(state multistep.StateBag if !s.UsePrivateIp { operatorName := ucloud.String("International") if strings.HasPrefix(s.Region, "cn-") { - operatorName = ucloud.String("BGP") + operatorName = ucloud.String("Bgp") } networkInterface := uhost.CreateUHostInstanceParamNetworkInterface{ EIP: &uhost.CreateUHostInstanceParamNetworkInterfaceEIP{ diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index 1223b3257..dd1eb7453 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -19,11 +19,12 @@ import ( ) const ( - BuilderId = "packer.post-processor.ucloud-import" - RAWFileFormat = "raw" - VHDFileFormat = "vhd" - VMDKFileFormat = "vmdk" - QCOW2FileFormat = "qcow2" + BuilderId = "packer.post-processor.ucloud-import" + + ImageFileFormatRAW = "raw" + ImageFileFormatVHD = "vhd" + ImageFileFormatVMDK = "vmdk" + ImageFileFormatQCOW2 = "qcow2" ) var regionForFileMap = ucloudcommon.NewStringConverter(map[string]string{ @@ -81,7 +82,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } if p.config.WaitImageReadyTimeout <= 0 { - p.config.WaitImageReadyTimeout = ucloudcommon.DefaultCreateImageTimeOut + p.config.WaitImageReadyTimeout = ucloudcommon.DefaultCreateImageTimeout } errs := new(packer.MultiError) @@ -117,7 +118,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } switch p.config.Format { - case VHDFileFormat, RAWFileFormat, VMDKFileFormat, QCOW2FileFormat: + case ImageFileFormatVHD, ImageFileFormatRAW, ImageFileFormatVMDK, ImageFileFormatQCOW2: default: errs = packer.MultiErrorAppend( errs, fmt.Errorf("expected %q only be one of 'raw', 'vhd', 'vmdk', or 'qcow2', got %q", "format", p.config.Format))