spelling: delete
This commit is contained in:
parent
dfcd5742cc
commit
939e7d5587
@ -89,7 +89,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||||||
steps = []multistep.Step{
|
steps = []multistep.Step{
|
||||||
&stepPreValidate{
|
&stepPreValidate{
|
||||||
AlicloudDestImageName: b.config.AlicloudImageName,
|
AlicloudDestImageName: b.config.AlicloudImageName,
|
||||||
ForceDelete: b.config.AlicloudImageForceDetele,
|
ForceDelete: b.config.AlicloudImageForceDelete,
|
||||||
},
|
},
|
||||||
&stepCheckAlicloudSourceImage{
|
&stepCheckAlicloudSourceImage{
|
||||||
SourceECSImageId: b.config.AlicloudSourceImage,
|
SourceECSImageId: b.config.AlicloudSourceImage,
|
||||||
@ -165,8 +165,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||||||
ForceStop: b.config.ForceStopInstance,
|
ForceStop: b.config.ForceStopInstance,
|
||||||
},
|
},
|
||||||
&stepDeleteAlicloudImageSnapshots{
|
&stepDeleteAlicloudImageSnapshots{
|
||||||
AlicloudImageForceDeteleSnapshots: b.config.AlicloudImageForceDeteleSnapshots,
|
AlicloudImageForceDeleteSnapshots: b.config.AlicloudImageForceDeleteSnapshots,
|
||||||
AlicloudImageForceDetele: b.config.AlicloudImageForceDetele,
|
AlicloudImageForceDelete: b.config.AlicloudImageForceDelete,
|
||||||
AlicloudImageName: b.config.AlicloudImageName,
|
AlicloudImageName: b.config.AlicloudImageName,
|
||||||
},
|
},
|
||||||
&stepCreateAlicloudImage{},
|
&stepCreateAlicloudImage{},
|
||||||
|
@ -32,8 +32,8 @@ type AlicloudImageConfig struct {
|
|||||||
AlicloudImageUNShareAccounts []string `mapstructure:"image_unshare_account"`
|
AlicloudImageUNShareAccounts []string `mapstructure:"image_unshare_account"`
|
||||||
AlicloudImageDestinationRegions []string `mapstructure:"image_copy_regions"`
|
AlicloudImageDestinationRegions []string `mapstructure:"image_copy_regions"`
|
||||||
AlicloudImageDestinationNames []string `mapstructure:"image_copy_names"`
|
AlicloudImageDestinationNames []string `mapstructure:"image_copy_names"`
|
||||||
AlicloudImageForceDetele bool `mapstructure:"image_force_delete"`
|
AlicloudImageForceDelete bool `mapstructure:"image_force_delete"`
|
||||||
AlicloudImageForceDeteleSnapshots bool `mapstructure:"image_force_delete_snapshots"`
|
AlicloudImageForceDeleteSnapshots bool `mapstructure:"image_force_delete_snapshots"`
|
||||||
AlicloudImageForceDeleteInstances bool `mapstructure:"image_force_delete_instances"`
|
AlicloudImageForceDeleteInstances bool `mapstructure:"image_force_delete_instances"`
|
||||||
AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation"`
|
AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation"`
|
||||||
AlicloudDiskDevices `mapstructure:",squash"`
|
AlicloudDiskDevices `mapstructure:",squash"`
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type stepDeleteAlicloudImageSnapshots struct {
|
type stepDeleteAlicloudImageSnapshots struct {
|
||||||
AlicloudImageForceDetele bool
|
AlicloudImageForceDelete bool
|
||||||
AlicloudImageForceDeteleSnapshots bool
|
AlicloudImageForceDeleteSnapshots bool
|
||||||
AlicloudImageName string
|
AlicloudImageName string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(_ context.Context, state multiste
|
|||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
ui.Say("Deleting image snapshots.")
|
ui.Say("Deleting image snapshots.")
|
||||||
// Check for force delete
|
// Check for force delete
|
||||||
if s.AlicloudImageForceDetele {
|
if s.AlicloudImageForceDelete {
|
||||||
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
||||||
RegionId: common.Region(config.AlicloudRegion),
|
RegionId: common.Region(config.AlicloudRegion),
|
||||||
ImageName: s.AlicloudImageName,
|
ImageName: s.AlicloudImageName,
|
||||||
@ -43,7 +43,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(_ context.Context, state multiste
|
|||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
if s.AlicloudImageForceDeteleSnapshots {
|
if s.AlicloudImageForceDeleteSnapshots {
|
||||||
for _, diskDevice := range image.DiskDeviceMappings.DiskDeviceMapping {
|
for _, diskDevice := range image.DiskDeviceMappings.DiskDeviceMapping {
|
||||||
if err := client.DeleteSnapshot(diskDevice.SnapshotId); err != nil {
|
if err := client.DeleteSnapshot(diskDevice.SnapshotId); err != nil {
|
||||||
err := fmt.Errorf("Deleting ECS snapshot failed: %s", err)
|
err := fmt.Errorf("Deleting ECS snapshot failed: %s", err)
|
||||||
|
@ -60,7 +60,7 @@ type Config struct {
|
|||||||
Architecture string `mapstructure:"image_architecture"`
|
Architecture string `mapstructure:"image_architecture"`
|
||||||
Size string `mapstructure:"image_system_size"`
|
Size string `mapstructure:"image_system_size"`
|
||||||
Format string `mapstructure:"format"`
|
Format string `mapstructure:"format"`
|
||||||
AlicloudImageForceDetele bool `mapstructure:"image_force_delete"`
|
AlicloudImageForceDelete bool `mapstructure:"image_force_delete"`
|
||||||
|
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||||||
getEndPonit(p.config.OSSBucket), p.config.OSSKey, err)
|
getEndPonit(p.config.OSSBucket), p.config.OSSKey, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(images) > 0 && !p.config.AlicloudImageForceDetele {
|
if len(images) > 0 && !p.config.AlicloudImageForceDelete {
|
||||||
return nil, false, fmt.Errorf("Duplicated image exists, please delete the existing images " +
|
return nil, false, fmt.Errorf("Duplicated image exists, please delete the existing images " +
|
||||||
"or set the 'image_force_delete' value as true")
|
"or set the 'image_force_delete' value as true")
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, fmt.Errorf("Failed to upload image %s: %s", source, err)
|
return nil, false, fmt.Errorf("Failed to upload image %s: %s", source, err)
|
||||||
}
|
}
|
||||||
if len(images) > 0 && p.config.AlicloudImageForceDetele {
|
if len(images) > 0 && p.config.AlicloudImageForceDelete {
|
||||||
if err = ecsClient.DeleteImage(packercommon.Region(p.config.AlicloudRegion),
|
if err = ecsClient.DeleteImage(packercommon.Region(p.config.AlicloudRegion),
|
||||||
images[0].ImageId); err != nil {
|
images[0].ImageId); err != nil {
|
||||||
return nil, false, fmt.Errorf("Delete duplicated image %s failed", images[0].ImageName)
|
return nil, false, fmt.Errorf("Delete duplicated image %s failed", images[0].ImageName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user