moved the warning into Prepare() and updated the invocation

pull/9964/head
James Griffith 6 years ago committed by Megan Marsh
parent 572de129d7
commit 09edada93d

@ -11,6 +11,7 @@ import (
"time"
"github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
)
@ -33,14 +34,17 @@ type ShutdownConfig struct {
DisableShutdown bool `mapstructure:"disable_shutdown"`
}
func (c *ShutdownConfig) Prepare() []error {
var errs []error
func (c *ShutdownConfig) Prepare(comm communicator.Config) (warnings []string, errs []error) {
if c.Timeout == 0 {
c.Timeout = 5 * time.Minute
}
return errs
if comm.Type == "none" && c.Command != "" {
warnings = append(warnings, "The parameter `shutdown_command` is ignored as it requires a `communicator`.")
}
return
}
type StepShutdown struct {
@ -59,11 +63,6 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis
if state.Get("communicator") == nil {
ui.Say("The `communicator` is 'none', automatic shutdown disabled.")
if s.Config.Command != "" {
ui.Message("The parameter `shutdown_command` is ignored as it requires a `communicator`.")
}
msg := fmt.Sprintf("Please shutdown virtual machine within %s.", s.Config.Timeout)
ui.Message(msg)

@ -86,7 +86,11 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare()...)
shutdownWarnings, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm)
warnings = append(warnings, shutdownWarnings...)
errs = packer.MultiErrorAppend(errs, shutdownErrs...)
if c.Export != nil {
errs = packer.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...)
}

Loading…
Cancel
Save