github.phpd.cn/hashicorp/packer@v1.3.2/builder/vmware/common/shutdown_config.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/hashicorp/packer/template/interpolate" 8 ) 9 10 type ShutdownConfig struct { 11 ShutdownCommand string `mapstructure:"shutdown_command"` 12 RawShutdownTimeout string `mapstructure:"shutdown_timeout"` 13 14 ShutdownTimeout time.Duration `` 15 } 16 17 func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error { 18 if c.RawShutdownTimeout == "" { 19 c.RawShutdownTimeout = "5m" 20 } 21 22 var errs []error 23 var err error 24 c.ShutdownTimeout, err = time.ParseDuration(c.RawShutdownTimeout) 25 if err != nil { 26 errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err)) 27 } 28 29 return errs 30 }