mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-27 18:24:01 -04:00
moved the warning into Prepare() and updated the invocation
This commit is contained in:
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)...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user