Skip to content

Commit

Permalink
Add skip_import parameter (#121)
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Este-Gracias <[email protected]>
  • Loading branch information
sestegra authored Oct 14, 2021
1 parent bbb1db3 commit 558edf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions builder/vsphere/common/step_import_to_content_library.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type ContentLibraryDestinationConfig struct {
Destroy bool `mapstructure:"destroy"`
// When set to true, Packer will import and OVF template to the content library item. Defaults to `false`.
Ovf bool `mapstructure:"ovf"`
// When set to true, the VM won't be imported to the content library item. Useful for setting to `true` during a build test stage. Defaults to `false`.
SkipImport bool `mapstructure:"skip_import"`
}

func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error {
Expand Down Expand Up @@ -118,6 +120,11 @@ type StepImportToContentLibrary struct {

func (s *StepImportToContentLibrary) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packersdk.Ui)
if s.ContentLibConfig.SkipImport {
ui.Say("Skipping import...")
return multistep.ActionContinue
}

vm := state.Get("vm").(*driver.VirtualMachineDriver)
var err error

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@

- `ovf` (bool) - When set to true, Packer will import and OVF template to the content library item. Defaults to `false`.

- `skip_import` (bool) - When set to true, the VM won't be imported to the content library item. Useful for setting to `true` during a build test stage. Defaults to `false`.

<!-- End of code generated from the comments of the ContentLibraryDestinationConfig struct in builder/vsphere/common/step_import_to_content_library.go; -->

0 comments on commit 558edf1

Please sign in to comment.