From 0174a502eb83bf255dfd9cad93b831e5f1bb8086 Mon Sep 17 00:00:00 2001 From: "bozhi.ch" Date: Wed, 5 Dec 2018 09:45:37 +0800 Subject: [PATCH] support -force option and update docs --- builder/alicloud/ecs/builder.go | 5 +++++ .../alicloud/ecs/step_delete_images_snapshots.go | 2 +- website/source/docs/builders/alicloud-ecs.html.md | 14 +++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 5894c3cd6..03df7fa04 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -57,6 +57,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { return nil, err } + if b.config.PackerConfig.PackerForce { + b.config.AlicloudImageForceDelete = true + b.config.AlicloudImageForceDeleteSnapshots = true + } + // Accumulate any errors var errs *packer.MultiError errs = packer.MultiErrorAppend(errs, b.config.AlicloudAccessConfig.Prepare(&b.config.ctx)...) diff --git a/builder/alicloud/ecs/step_delete_images_snapshots.go b/builder/alicloud/ecs/step_delete_images_snapshots.go index f5bebfc19..68b9cee12 100644 --- a/builder/alicloud/ecs/step_delete_images_snapshots.go +++ b/builder/alicloud/ecs/step_delete_images_snapshots.go @@ -93,4 +93,4 @@ func (s *stepDeleteAlicloudImageSnapshots) deleteImageAndSnapshots(state multist } func (s *stepDeleteAlicloudImageSnapshots) Cleanup(state multistep.StateBag) { -} \ No newline at end of file +} diff --git a/website/source/docs/builders/alicloud-ecs.html.md b/website/source/docs/builders/alicloud-ecs.html.md index 8b46a4c2e..8585cee65 100644 --- a/website/source/docs/builders/alicloud-ecs.html.md +++ b/website/source/docs/builders/alicloud-ecs.html.md @@ -158,13 +158,17 @@ builder. those disks containing lots of data, it may require a higher timeout value. - `image_force_delete` (boolean) - If this value is true, when the target - image name is duplicated with an existing image, it will delete the - existing image and then create the target image, otherwise, the creation - will fail. The default value is false. + image names including those copied are duplicated with existing images, + it will delete the existing images and then create the target images, + otherwise, the creation will fail. The default value is false. Check + `image_name` and `image_copy_names` options for names of target images. + If [-force](https://packer.io/docs/commands/build.html#force) option is provided + in `build` command, this option can be omitted and taken as true. - `image_force_delete_snapshots` (boolean) - If this value is true, when - delete the duplicated existing image, the source snapshot of this image - will be delete either. + delete the duplicated existing images, the source snapshots of those images + will be delete either. If [-force](https://packer.io/docs/commands/build.html#force) + option is provided in `build` command, this option can be omitted and taken as true. - `image_share_account` (array of string) - The IDs of to-be-added Aliyun accounts to which the image is shared. The number of accounts is 1 to 10.