Skip to content

Commit

Permalink
Skip superfluous image name validation when "skip_create_image" is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Dec 5, 2024
1 parent db1d7e3 commit f6bf78e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builder/tencentcloud/cvm/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
// Build the steps
var steps []multistep.Step
steps = []multistep.Step{
&stepPreValidate{},
&stepPreValidate{
b.config.SkipCreateImage,
},
&stepCheckSourceImage{
b.config.SourceImageId,
},
Expand Down
6 changes: 6 additions & 0 deletions builder/tencentcloud/cvm/step_pre_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ import (
)

type stepPreValidate struct {
SkipCreateImage bool
}

func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
// No need to validate the image name if we're not creating an image
if s.SkipCreateImage {
return multistep.ActionContinue
}

config := state.Get("config").(*Config)
client := state.Get("cvm_client").(*cvm.Client)

Expand Down

0 comments on commit f6bf78e

Please sign in to comment.