Files
Packer-Cn/builder/vsphere/common/step_template.go
T

32 lines
718 B
Go
Raw Normal View History

2018-01-24 14:04:39 +03:00
package common
2017-06-13 14:11:41 +03:00
import (
2018-11-01 00:42:24 +03:00
"context"
2020-02-14 11:42:29 -05:00
"github.com/hashicorp/packer/builder/vsphere/driver"
2018-04-25 14:22:38 +03:00
"github.com/hashicorp/packer/helper/multistep"
2017-06-13 14:11:41 +03:00
"github.com/hashicorp/packer/packer"
)
2018-11-01 00:42:24 +03:00
type StepConvertToTemplate struct {
2017-06-27 10:32:59 +03:00
ConvertToTemplate bool
2017-06-13 14:11:41 +03:00
}
2018-04-25 14:22:38 +03:00
func (s *StepConvertToTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
2017-06-13 14:11:41 +03:00
ui := state.Get("ui").(packer.Ui)
2017-08-24 03:06:50 +03:00
vm := state.Get("vm").(*driver.VirtualMachine)
2017-06-13 14:11:41 +03:00
2017-06-27 10:32:59 +03:00
if s.ConvertToTemplate {
2017-07-02 18:00:43 +03:00
ui.Say("Convert VM into template...")
2017-08-24 03:06:50 +03:00
err := vm.ConvertToTemplate()
2017-06-13 14:11:41 +03:00
if err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
}
return multistep.ActionContinue
}
2017-06-27 10:32:59 +03:00
func (s *StepConvertToTemplate) Cleanup(state multistep.StateBag) {}