package common import ( "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/jetbrains-infra/packer-builder-vsphere/driver" "context" ) type StepCreateSnapshot struct{ CreateSnapshot bool } func (s *StepCreateSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vm := state.Get("vm").(*driver.VirtualMachine) if s.CreateSnapshot { ui.Say("Creating snapshot...") err := vm.CreateSnapshot("Created by Packer") if err != nil { state.Put("error", err) return multistep.ActionHalt } } return multistep.ActionContinue } func (s *StepCreateSnapshot) Cleanup(state multistep.StateBag) {}