optimize code style
This commit is contained in:
parent
9de1c42ad4
commit
37e898e115
@ -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{
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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{
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user