Skip to content

Commit

Permalink
feat: support skip create image
Browse files Browse the repository at this point in the history
  • Loading branch information
newbieJerry committed Dec 17, 2022
1 parent 27597ad commit 58f7eeb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 52 deletions.
45 changes: 20 additions & 25 deletions builder/ecs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,32 +202,27 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
})
}

if b.config.SkipCreateImage {
steps = append(steps, &stepStopBuilder{
Message: SkipCreateImage,
})
if !b.config.SkipCreateImage {
steps = append(steps,
&stepCreateAlicloudImage{
AlicloudImageIgnoreDataDisks: b.config.AlicloudImageIgnoreDataDisks,
WaitSnapshotReadyTimeout: b.getSnapshotReadyTimeout(),
},
&stepCreateTags{
Tags: b.config.AlicloudImageTags,
},
&stepRegionCopyAlicloudImage{
AlicloudImageDestinationRegions: b.config.AlicloudImageDestinationRegions,
AlicloudImageDestinationNames: b.config.AlicloudImageDestinationNames,
RegionId: b.config.AlicloudRegion,
WaitCopyingImageReadyTimeout: b.getCopyingImageReadyTimeout(),
},
&stepShareAlicloudImage{
AlicloudImageShareAccounts: b.config.AlicloudImageShareAccounts,
AlicloudImageUNShareAccounts: b.config.AlicloudImageUNShareAccounts,
RegionId: b.config.AlicloudRegion,
})
}

steps = append(steps,
&stepCreateAlicloudImage{
AlicloudImageIgnoreDataDisks: b.config.AlicloudImageIgnoreDataDisks,
WaitSnapshotReadyTimeout: b.getSnapshotReadyTimeout(),
},
&stepCreateTags{
Tags: b.config.AlicloudImageTags,
},
&stepRegionCopyAlicloudImage{
AlicloudImageDestinationRegions: b.config.AlicloudImageDestinationRegions,
AlicloudImageDestinationNames: b.config.AlicloudImageDestinationNames,
RegionId: b.config.AlicloudRegion,
WaitCopyingImageReadyTimeout: b.getCopyingImageReadyTimeout(),
},
&stepShareAlicloudImage{
AlicloudImageShareAccounts: b.config.AlicloudImageShareAccounts,
AlicloudImageUNShareAccounts: b.config.AlicloudImageUNShareAccounts,
RegionId: b.config.AlicloudRegion,
})

// Run!
b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui)
b.runner.Run(ctx, state)
Expand Down
2 changes: 1 addition & 1 deletion builder/ecs/run_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type RunConfig struct {
// the ECS created through private ip instead of allocating a public ip or an
// EIP. The default value is false.
SSHPrivateIp bool `mapstructure:"ssh_private_ip" required:"false"`
//If this value is true, packer will skip create image
//If true, Packer will not create a final image. Defaults to `false`.
SkipCreateImage bool `mapstructure:"skip_create_image" required:"false"`
}

Expand Down
25 changes: 0 additions & 25 deletions builder/ecs/step_stop_builder.go

This file was deleted.

2 changes: 1 addition & 1 deletion docs-partials/builder/ecs/RunConfig-not-required.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@
the ECS created through private ip instead of allocating a public ip or an
EIP. The default value is false.

- `skip_create_image` (bool) - If this value is true, packer will not create image.
- `skip_create_image` (bool) - If true, Packer will not create a final image. Defaults to `false`.

<!-- End of code generated from the comments of the RunConfig struct in builder/ecs/run_config.go; -->

0 comments on commit 58f7eeb

Please sign in to comment.