packer-cn/iso/step_config_params.go

38 lines
939 B
Go
Raw Normal View History

2018-02-26 16:18:06 -05:00
package iso
import (
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
2018-04-25 07:22:38 -04:00
"github.com/hashicorp/packer/helper/multistep"
2018-02-26 16:18:06 -05:00
"fmt"
2018-04-25 07:22:38 -04:00
"context"
2018-02-26 16:18:06 -05:00
)
type ConfigParamsConfig struct {
ConfigParams map[string]string `mapstructure:"configuration_parameters"`
}
func (c *ConfigParamsConfig) Prepare() []error {
return nil
}
type StepConfigParams struct {
Config *ConfigParamsConfig
}
2018-04-25 07:22:38 -04:00
func (s *StepConfigParams) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
2018-02-26 16:18:06 -05:00
ui := state.Get("ui").(packer.Ui)
vm := state.Get("vm").(*driver.VirtualMachine)
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) {}