9ec8b67392
* 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
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
//go:generate struct-markdown
|
|
//go:generate mapstructure-to-hcl2 -type ConfigParamsConfig
|
|
|
|
package common
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/packer/builder/vsphere/driver"
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
"github.com/hashicorp/packer/packer"
|
|
)
|
|
|
|
type ConfigParamsConfig struct {
|
|
// Custom parameters.
|
|
ConfigParams map[string]string `mapstructure:"configuration_parameters"`
|
|
}
|
|
|
|
type StepConfigParams struct {
|
|
Config *ConfigParamsConfig
|
|
}
|
|
|
|
func (s *StepConfigParams) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
ui := state.Get("ui").(packer.Ui)
|
|
vm := state.Get("vm").(*driver.VirtualMachine)
|
|
|
|
if s.Config.ConfigParams != nil {
|
|
ui.Say("Adding configuration parameters...")
|
|
if err := vm.AddConfigParams(s.Config.ConfigParams); err != nil {
|
|
state.Put("error", fmt.Errorf("error adding configuration parameters: %v", err))
|
|
return multistep.ActionHalt
|
|
}
|
|
}
|
|
|
|
return multistep.ActionContinue
|
|
}
|
|
|
|
func (s *StepConfigParams) Cleanup(state multistep.StateBag) {}
|