2019-06-14 06:43:12 -04:00
|
|
|
//go:generate struct-markdown
|
|
|
|
|
2019-06-13 11:23:21 -04:00
|
|
|
package shutdowncommand
|
2015-06-21 09:06:27 -04:00
|
|
|
|
|
|
|
import (
|
2019-10-31 10:49:34 -04:00
|
|
|
"time"
|
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2015-06-21 09:06:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type ShutdownConfig struct {
|
2019-06-14 06:43:12 -04:00
|
|
|
// The command to use to gracefully shut down the machine once all
|
|
|
|
// provisioning is complete. By default this is an empty string, which
|
|
|
|
// tells Packer to just forcefully shut down the machine. This setting can
|
|
|
|
// be safely omitted if for example, a shutdown command to gracefully halt
|
|
|
|
// the machine is configured inside a provisioning script. If one or more
|
|
|
|
// scripts require a reboot it is suggested to leave this blank (since
|
|
|
|
// reboots may fail) and instead specify the final shutdown command in your
|
|
|
|
// last script.
|
2019-06-06 10:29:25 -04:00
|
|
|
ShutdownCommand string `mapstructure:"shutdown_command" required:"false"`
|
2019-06-14 06:43:12 -04:00
|
|
|
// The amount of time to wait after executing the shutdown_command for the
|
|
|
|
// virtual machine to actually shut down. If the machine doesn't shut down
|
|
|
|
// in this time it is considered an error. By default, the time out is "5m"
|
|
|
|
// (five minutes).
|
2019-10-31 10:49:34 -04:00
|
|
|
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" required:"false"`
|
2015-06-21 09:06:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error {
|
2019-10-31 10:49:34 -04:00
|
|
|
if c.ShutdownTimeout == 0 {
|
|
|
|
c.ShutdownTimeout = 5 * time.Minute
|
2015-06-21 09:06:27 -04:00
|
|
|
}
|
|
|
|
|
2019-10-31 06:31:17 -04:00
|
|
|
return nil
|
2015-06-21 09:06:27 -04:00
|
|
|
}
|