* Add golangci-lint as linting tool * Disable failing staticchecks to start; GitHub issue to handle coming soon * Run `goimports -w` to repair all source files that have improperly formatted imports * makefile: Add ci-lint target to run on travis This change adds a new make target for running golangci-lint on newly added Go files only. This target is expected to run during Packer ci builds. * .github/contributing: Add code linting instructions * travis: Update job configuration to run parallel builds
32 lines
718 B
Go
32 lines
718 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/packer/builder/vsphere/driver"
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
"github.com/hashicorp/packer/packer"
|
|
)
|
|
|
|
type StepConvertToTemplate struct {
|
|
ConvertToTemplate bool
|
|
}
|
|
|
|
func (s *StepConvertToTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
ui := state.Get("ui").(packer.Ui)
|
|
vm := state.Get("vm").(*driver.VirtualMachine)
|
|
|
|
if s.ConvertToTemplate {
|
|
ui.Say("Convert VM into template...")
|
|
err := vm.ConvertToTemplate()
|
|
if err != nil {
|
|
state.Put("error", err)
|
|
return multistep.ActionHalt
|
|
}
|
|
}
|
|
|
|
return multistep.ActionContinue
|
|
}
|
|
|
|
func (s *StepConvertToTemplate) Cleanup(state multistep.StateBag) {}
|