Merge pull request #8286 from hashicorp/template-durations-must-be-strings

Document duration strings better to avoid confusion
This commit is contained in:
Megan Marsh 2019-10-31 15:32:31 -07:00 committed by GitHub
commit 10ae0baa39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 185 additions and 399 deletions

View File

@ -8,9 +8,9 @@ import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/iam"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"

View File

@ -8,11 +8,11 @@ import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go/service/iam"
"os"
"strings"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/iam"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"

View File

@ -142,6 +142,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
var errs *packer.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
}

View File

@ -121,7 +121,7 @@ type Config struct {
// If true, launch a preemptible instance.
Preemptible bool `mapstructure:"preemptible" required:"false"`
// The time to wait for instance state changes. Defaults to "5m".
RawStateTimeout string `mapstructure:"state_timeout" required:"false"`
StateTimeout time.Duration `mapstructure:"state_timeout" required:"false"`
// The region in which to launch the instance. Defaults to the region
// hosting the specified zone.
Region string `mapstructure:"region" required:"false"`
@ -183,7 +183,6 @@ type Config struct {
Zone string `mapstructure:"zone" required:"true"`
account *jwt.Config
stateTimeout time.Duration
imageAlreadyExists bool
ctx interpolate.Context
}
@ -293,8 +292,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.MachineType = "n1-standard-1"
}
if c.RawStateTimeout == "" {
c.RawStateTimeout = "5m"
if c.StateTimeout == 0 {
c.StateTimeout = 5 * time.Minute
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
@ -330,11 +329,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.Region = region
}
err = c.CalcTimeout()
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
}
// Authenticating via an account file
if c.AccountFile != "" {
if c.VaultGCPOauthEngine != "" {
@ -384,15 +378,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
return c, nil, nil
}
func (c *Config) CalcTimeout() error {
stateTimeout, err := time.ParseDuration(c.RawStateTimeout)
if err != nil {
return fmt.Errorf("Failed parsing state_timeout: %s", err)
}
c.stateTimeout = stateTimeout
return nil
}
type CustomerEncryptionKey struct {
// KmsKeyName: The name of the encryption key that is stored in Google
// Cloud KMS.

View File

@ -82,7 +82,7 @@ type FlatConfig struct {
OmitExternalIP *bool `mapstructure:"omit_external_ip" required:"false" cty:"omit_external_ip"`
OnHostMaintenance *string `mapstructure:"on_host_maintenance" required:"false" cty:"on_host_maintenance"`
Preemptible *bool `mapstructure:"preemptible" required:"false" cty:"preemptible"`
RawStateTimeout *string `mapstructure:"state_timeout" required:"false" cty:"state_timeout"`
StateTimeout *string `mapstructure:"state_timeout" required:"false" cty:"state_timeout"`
Region *string `mapstructure:"region" required:"false" cty:"region"`
Scopes []string `mapstructure:"scopes" required:"false" cty:"scopes"`
ServiceAccountEmail *string `mapstructure:"service_account_email" required:"false" cty:"service_account_email"`

View File

@ -44,7 +44,7 @@ func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
var err error
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for image to register")
}

View File

@ -154,7 +154,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
ui.Message("Waiting for creation operation to complete...")
select {
case err = <-errCh:
case <-time.After(c.stateTimeout):
case <-time.After(c.StateTimeout):
err = errors.New("time out while waiting for instance to create")
}
}
@ -200,7 +200,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
if err == nil {
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for instance to delete")
}
}
@ -222,7 +222,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
if err == nil {
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for disk to delete")
}
}

View File

@ -232,7 +232,7 @@ func TestStepCreateInstance_errorTimeout(t *testing.T) {
errCh := make(chan error, 1)
config := state.Get("config").(*Config)
config.stateTimeout = 1 * time.Microsecond
config.StateTimeout = 1 * time.Millisecond
d := state.Get("driver").(*DriverMock)
d.RunInstanceErrCh = errCh

View File

@ -99,7 +99,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta
ui.Message("Waiting for windows password to complete...")
select {
case err = <-errCh:
case <-time.After(c.stateTimeout):
case <-time.After(c.StateTimeout):
err = errors.New("time out while waiting for the password to be created")
}
}

View File

@ -29,7 +29,7 @@ func (s *StepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) mu
var err error
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for instance to become running")
}

View File

@ -156,7 +156,7 @@ func TestStepInstanceInfo_errorTimeout(t *testing.T) {
state.Put("instance_name", "foo")
config := state.Get("config").(*Config)
config.stateTimeout = 1 * time.Microsecond
config.StateTimeout = 1 * time.Millisecond
driver := state.Get("driver").(*DriverMock)
driver.WaitForInstanceErrCh = errCh

View File

@ -34,7 +34,7 @@ func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag
if err == nil {
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for instance to delete")
}
}
@ -64,7 +64,7 @@ func (s *StepTeardownInstance) Cleanup(state multistep.StateBag) {
if err == nil {
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):
case <-time.After(config.StateTimeout):
err = errors.New("time out while waiting for disk to delete")
}
}

View File

@ -23,8 +23,9 @@ type Config struct {
common.PackerConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
HCloudToken string `mapstructure:"token"`
Endpoint string `mapstructure:"endpoint"`
HCloudToken string `mapstructure:"token"`
Endpoint string `mapstructure:"endpoint"`
PollInterval time.Duration `mapstructure:"poll_interval"`
ServerName string `mapstructure:"server_name"`

View File

@ -26,10 +26,9 @@ type FlatConfig struct {
ISOUrls []string `mapstructure:"iso_urls" cty:"iso_urls"`
TargetPath *string `mapstructure:"iso_target_path" cty:"iso_target_path"`
TargetExtension *string `mapstructure:"iso_target_extension" cty:"iso_target_extension"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
@ -99,7 +98,7 @@ type FlatConfig struct {
SkipExport *bool `mapstructure:"skip_export" required:"false" cty:"skip_export"`
Headless *bool `mapstructure:"headless" required:"false" cty:"headless"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
DiskSize *uint `mapstructure:"disk_size" required:"false" cty:"disk_size"`
UseLegacyNetworkAdapter *bool `mapstructure:"use_legacy_network_adapter" required:"false" cty:"use_legacy_network_adapter"`
DifferencingDisk *bool `mapstructure:"differencing_disk" required:"false" cty:"differencing_disk"`
@ -135,7 +134,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},

View File

@ -26,10 +26,9 @@ type FlatConfig struct {
ISOUrls []string `mapstructure:"iso_urls" cty:"iso_urls"`
TargetPath *string `mapstructure:"iso_target_path" cty:"iso_target_path"`
TargetExtension *string `mapstructure:"iso_target_extension" cty:"iso_target_extension"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
@ -99,7 +98,7 @@ type FlatConfig struct {
SkipExport *bool `mapstructure:"skip_export" required:"false" cty:"skip_export"`
Headless *bool `mapstructure:"headless" required:"false" cty:"headless"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
CloneFromVMCXPath *string `mapstructure:"clone_from_vmcx_path" cty:"clone_from_vmcx_path"`
CloneFromVMName *string `mapstructure:"clone_from_vm_name" cty:"clone_from_vm_name"`
CloneFromSnapshotName *string `mapstructure:"clone_from_snapshot_name" required:"false" cty:"clone_from_snapshot_name"`
@ -137,7 +136,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},

View File

@ -151,43 +151,6 @@ func TestBuilderPrepare_Image(t *testing.T) {
}
}
func TestBuilderPrepare_StateTimeout(t *testing.T) {
var b Builder
config := testConfig()
// Test default
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Test set
config["state_timeout"] = "5m"
b = Builder{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Test bad
config["state_timeout"] = "tubes"
b = Builder{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatal("should have error")
}
}
func TestBuilderPrepare_ImageLabel(t *testing.T) {
var b Builder
config := testConfig()

View File

@ -9,7 +9,6 @@ import (
"fmt"
"os"
"regexp"
"time"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
@ -36,10 +35,7 @@ type Config struct {
ImageLabel string `mapstructure:"image_label"`
Description string `mapstructure:"image_description"`
RawStateTimeout string `mapstructure:"state_timeout"`
stateTimeout time.Duration
interCtx interpolate.Context
interCtx interpolate.Context
}
func createRandomRootPassword() (string, error) {
@ -101,16 +97,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
if c.RawStateTimeout == "" {
c.stateTimeout = 5 * time.Minute
} else {
if stateTimeout, err := time.ParseDuration(c.RawStateTimeout); err == nil {
c.stateTimeout = stateTimeout
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to parse state timeout: %s", err))
}
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
}

View File

@ -67,7 +67,6 @@ type FlatConfig struct {
RootSSHKey *string `mapstructure:"root_ssh_key" cty:"root_ssh_key"`
ImageLabel *string `mapstructure:"image_label" cty:"image_label"`
Description *string `mapstructure:"image_description" cty:"image_description"`
RawStateTimeout *string `mapstructure:"state_timeout" cty:"state_timeout"`
}
// FlatMapstructure returns a new FlatConfig.
@ -137,7 +136,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"root_ssh_key": &hcldec.AttrSpec{Name: "root_ssh_key", Type: cty.String, Required: false},
"image_label": &hcldec.AttrSpec{Name: "image_label", Type: cty.String, Required: false},
"image_description": &hcldec.AttrSpec{Name: "image_description", Type: cty.String, Required: false},
"state_timeout": &hcldec.AttrSpec{Name: "state_timeout", Type: cty.String, Required: false},
}
return s
}

View File

@ -31,7 +31,8 @@ type Config struct {
CommandWrapper string `mapstructure:"command_wrapper" required:"false"`
// The timeout in seconds to wait for the the
// container to start. Defaults to 20 seconds.
RawInitTimeout string `mapstructure:"init_timeout" required:"false"`
InitTimeout time.Duration `mapstructure:"init_timeout" required:"false"`
// Options to pass to lxc-create. For
// instance, you can specify a custom LXC container configuration file with
// ["-f", "/path/to/lxc.conf"]. Defaults to []. See man 1 lxc-create for
@ -62,7 +63,6 @@ type Config struct {
// container to reach. Note some distributions (Ubuntu) simulate run levels
// and may report 5 rather than 3.
TargetRunlevel int `mapstructure:"target_runlevel" required:"false"`
InitTimeout time.Duration
ctx interpolate.Context
}
@ -98,13 +98,8 @@ func NewConfig(raws ...interface{}) (*Config, error) {
c.CommandWrapper = "{{.Command}}"
}
if c.RawInitTimeout == "" {
c.RawInitTimeout = "20s"
}
c.InitTimeout, err = time.ParseDuration(c.RawInitTimeout)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed parsing init_timeout: %s", err))
if c.InitTimeout == 0 {
c.InitTimeout = 20 * time.Second
}
if _, err := os.Stat(c.ConfigFile); os.IsNotExist(err) {

View File

@ -29,10 +29,9 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
CpuCount *int `mapstructure:"cpus" required:"false" cty:"cpus"`
MemorySize *int `mapstructure:"memory" required:"false" cty:"memory"`
@ -42,7 +41,7 @@ type FlatConfig struct {
PrlctlPost [][]string `mapstructure:"prlctl_post" required:"false" cty:"prlctl_post"`
PrlctlVersionFile *string `mapstructure:"prlctl_version_file" required:"false" cty:"prlctl_version_file"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -128,7 +127,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},
"cpus": &hcldec.AttrSpec{Name: "cpus", Type: cty.Number, Required: false},
"memory": &hcldec.AttrSpec{Name: "memory", Type: cty.Number, Required: false},

View File

@ -65,11 +65,10 @@ type FlatConfig struct {
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
SSHWaitTimeout *string `mapstructure:"ssh_wait_timeout" cty:"ssh_wait_timeout"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
ParallelsToolsFlavor *string `mapstructure:"parallels_tools_flavor" required:"true" cty:"parallels_tools_flavor"`
ParallelsToolsGuestPath *string `mapstructure:"parallels_tools_guest_path" required:"false" cty:"parallels_tools_guest_path"`
ParallelsToolsMode *string `mapstructure:"parallels_tools_mode" required:"false" cty:"parallels_tools_mode"`
@ -148,7 +147,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"parallels_tools_flavor": &hcldec.AttrSpec{Name: "parallels_tools_flavor", Type: cty.String, Required: false},
"parallels_tools_guest_path": &hcldec.AttrSpec{Name: "parallels_tools_guest_path", Type: cty.String, Required: false},
"parallels_tools_mode": &hcldec.AttrSpec{Name: "parallels_tools_mode", Type: cty.String, Required: false},

View File

@ -24,8 +24,7 @@ type Config struct {
common.PackerConfig `mapstructure:",squash"`
common.HTTPConfig `mapstructure:",squash"`
bootcommand.BootConfig `mapstructure:",squash"`
RawBootKeyInterval string `mapstructure:"boot_key_interval"`
BootKeyInterval time.Duration ``
BootKeyInterval time.Duration `mapstructure:"boot_key_interval"`
Comm communicator.Config `mapstructure:",squash"`
ProxmoxURLRaw string `mapstructure:"proxmox_url"`
@ -104,18 +103,16 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
if c.Password == "" {
c.Password = os.Getenv("PROXMOX_PASSWORD")
}
if c.RawBootKeyInterval == "" {
c.RawBootKeyInterval = os.Getenv(common.PackerKeyEnv)
}
if c.RawBootKeyInterval == "" {
c.BootKeyInterval = 5 * time.Millisecond
} else {
if interval, err := time.ParseDuration(c.RawBootKeyInterval); err == nil {
c.BootKeyInterval = interval
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Could not parse boot_key_interval: %v", err))
if c.BootKeyInterval == 0 && os.Getenv(common.PackerKeyEnv) != "" {
var err error
c.BootKeyInterval, err = time.ParseDuration(os.Getenv(common.PackerKeyEnv))
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
}
}
if c.BootKeyInterval == 0 {
c.BootKeyInterval = 5 * time.Millisecond
}
if c.VMName == "" {
// Default to packer-[time-ordered-uuid]

View File

@ -19,11 +19,10 @@ type FlatConfig struct {
HTTPDir *string `mapstructure:"http_directory" cty:"http_directory"`
HTTPPortMin *int `mapstructure:"http_port_min" cty:"http_port_min"`
HTTPPortMax *int `mapstructure:"http_port_max" cty:"http_port_max"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
RawBootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
BootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -109,7 +108,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"boot_key_interval": &hcldec.AttrSpec{Name: "boot_key_interval", Type: cty.String, Required: false},
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},

View File

@ -47,7 +47,7 @@ func (s *stepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
}
if int64(s.BootWait) > 0 {
ui.Say(fmt.Sprintf("Waiting %s for boot", s.BootWait.String()))
ui.Say(fmt.Sprintf("Waiting %s for boot", s.BootWait))
select {
case <-time.After(s.BootWait):
break

View File

@ -26,14 +26,13 @@ type FlatConfig struct {
ISOUrls []string `mapstructure:"iso_urls" cty:"iso_urls"`
TargetPath *string `mapstructure:"iso_target_path" cty:"iso_target_path"`
TargetExtension *string `mapstructure:"iso_target_extension" cty:"iso_target_extension"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
DisableVNC *bool `mapstructure:"disable_vnc" cty:"disable_vnc"`
RawBootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
BootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -141,7 +140,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"disable_vnc": &hcldec.AttrSpec{Name: "disable_vnc", Type: cty.Bool, Required: false},
"boot_key_interval": &hcldec.AttrSpec{Name: "boot_key_interval", Type: cty.String, Required: false},
"shutdown_command": &hcldec.AttrSpec{Name: "shutdown_command", Type: cty.String, Required: false},

View File

@ -51,7 +51,7 @@ func (s *stepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
// Wait the for the vm to boot.
if int64(config.BootWait) > 0 {
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait.String()))
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait))
select {
case <-time.After(config.BootWait):
break

View File

@ -29,10 +29,9 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -130,7 +129,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},

View File

@ -3,7 +3,6 @@
package common
import (
"fmt"
"time"
"github.com/hashicorp/packer/template/interpolate"
@ -22,37 +21,18 @@ type ShutdownConfig struct {
// shutdown_command for the virtual machine to actually shut down. If it
// doesn't shut down in this time, it is an error. By default, the timeout is
// 5m or five minutes.
RawShutdownTimeout string `mapstructure:"shutdown_timeout" required:"false"`
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" required:"false"`
// The amount of time to wait after shutting
// down the virtual machine. If you get the error
// Error removing floppy controller, you might need to set this to 5m
// or so. By default, the delay is 0s or disabled.
RawPostShutdownDelay string `mapstructure:"post_shutdown_delay" required:"false"`
ShutdownTimeout time.Duration ``
PostShutdownDelay time.Duration ``
PostShutdownDelay time.Duration `mapstructure:"post_shutdown_delay" required:"false"`
}
func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error {
if c.RawShutdownTimeout == "" {
c.RawShutdownTimeout = "5m"
if c.ShutdownTimeout == 0 {
c.ShutdownTimeout = 5 * time.Minute
}
if c.RawPostShutdownDelay == "" {
c.RawPostShutdownDelay = "0s"
}
var errs []error
var err error
c.ShutdownTimeout, err = time.ParseDuration(c.RawShutdownTimeout)
if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err))
}
c.PostShutdownDelay, err = time.ParseDuration(c.RawPostShutdownDelay)
if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing post_shutdown_delay: %s", err))
}
return errs
return nil
}

View File

@ -26,17 +26,9 @@ func TestShutdownConfigPrepare_ShutdownTimeout(t *testing.T) {
var c *ShutdownConfig
var errs []error
// Test with a bad value
c = testShutdownConfig()
c.RawShutdownTimeout = "this is not good"
errs = c.Prepare(interpolate.NewContext())
if len(errs) == 0 {
t.Fatalf("should have error")
}
// Test with a good one
c = testShutdownConfig()
c.RawShutdownTimeout = "5s"
c.ShutdownTimeout = 5 * time.Second
errs = c.Prepare(interpolate.NewContext())
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
@ -50,17 +42,9 @@ func TestShutdownConfigPrepare_PostShutdownDelay(t *testing.T) {
var c *ShutdownConfig
var errs []error
// Test with a bad value
c = testShutdownConfig()
c.RawPostShutdownDelay = "this is not good"
errs = c.Prepare(interpolate.NewContext())
if len(errs) == 0 {
t.Fatalf("should have error")
}
// Test with default value
c = testShutdownConfig()
c.RawPostShutdownDelay = ""
c.PostShutdownDelay = 0
errs = c.Prepare(interpolate.NewContext())
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
@ -71,12 +55,12 @@ func TestShutdownConfigPrepare_PostShutdownDelay(t *testing.T) {
// Test with a good one
c = testShutdownConfig()
c.RawPostShutdownDelay = "5s"
c.PostShutdownDelay = 5 * time.Millisecond
errs = c.Prepare(interpolate.NewContext())
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
}
if c.PostShutdownDelay != 5*time.Second {
if c.PostShutdownDelay != 5*time.Millisecond {
t.Fatalf("bad: %s", c.PostShutdownDelay)
}
}

View File

@ -29,10 +29,9 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
Format *string `mapstructure:"format" required:"false" cty:"format"`
ExportOpts []string `mapstructure:"export_opts" required:"false" cty:"export_opts"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
@ -41,8 +40,8 @@ type FlatConfig struct {
VRDPPortMin *int `mapstructure:"vrdp_port_min" required:"false" cty:"vrdp_port_min"`
VRDPPortMax *int `mapstructure:"vrdp_port_max" cty:"vrdp_port_max"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
RawPostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
PostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -144,7 +143,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"format": &hcldec.AttrSpec{Name: "format", Type: cty.String, Required: false},
"export_opts": &hcldec.AttrSpec{Name: "export_opts", Type: cty.List(cty.String), Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},

View File

@ -22,10 +22,9 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
Format *string `mapstructure:"format" required:"false" cty:"format"`
ExportOpts []string `mapstructure:"export_opts" required:"false" cty:"export_opts"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
@ -78,8 +77,8 @@ type FlatConfig struct {
SSHSkipNatMapping *bool `mapstructure:"ssh_skip_nat_mapping" required:"false" cty:"ssh_skip_nat_mapping"`
SSHWaitTimeout *string `mapstructure:"ssh_wait_timeout" cty:"ssh_wait_timeout"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
RawPostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
PostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
VBoxManage [][]string `mapstructure:"vboxmanage" required:"false" cty:"vboxmanage"`
VBoxManagePost [][]string `mapstructure:"vboxmanage_post" required:"false" cty:"vboxmanage_post"`
VBoxVersionFile *string `mapstructure:"virtualbox_version_file" required:"false" cty:"virtualbox_version_file"`
@ -124,7 +123,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"format": &hcldec.AttrSpec{Name: "format", Type: cty.String, Required: false},
"export_opts": &hcldec.AttrSpec{Name: "export_opts", Type: cty.List(cty.String), Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},

View File

@ -6,6 +6,7 @@ import (
"fmt"
"log"
"strings"
"time"
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
"github.com/hashicorp/packer/common"
@ -71,8 +72,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.GuestAdditionsPath = "VBoxGuestAdditions.iso"
}
if c.RawPostShutdownDelay == "" {
c.RawPostShutdownDelay = "2s"
if c.PostShutdownDelay == 0 {
c.PostShutdownDelay = 2 * time.Second
}
// Prepare the errors
@ -88,7 +89,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
log.Printf("PostShutdownDelay: %f", c.PostShutdownDelay.Seconds())
log.Printf("PostShutdownDelay: %s", c.PostShutdownDelay)
if c.VMName == "" {
errs = packer.MultiErrorAppend(errs,

View File

@ -22,10 +22,9 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
Format *string `mapstructure:"format" required:"false" cty:"format"`
ExportOpts []string `mapstructure:"export_opts" required:"false" cty:"export_opts"`
OutputDir *string `mapstructure:"output_directory" required:"false" cty:"output_directory"`
@ -78,8 +77,8 @@ type FlatConfig struct {
SSHSkipNatMapping *bool `mapstructure:"ssh_skip_nat_mapping" required:"false" cty:"ssh_skip_nat_mapping"`
SSHWaitTimeout *string `mapstructure:"ssh_wait_timeout" cty:"ssh_wait_timeout"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
RawPostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
PostShutdownDelay *string `mapstructure:"post_shutdown_delay" required:"false" cty:"post_shutdown_delay"`
VBoxManage [][]string `mapstructure:"vboxmanage" required:"false" cty:"vboxmanage"`
VBoxManagePost [][]string `mapstructure:"vboxmanage_post" required:"false" cty:"vboxmanage_post"`
VBoxVersionFile *string `mapstructure:"virtualbox_version_file" required:"false" cty:"virtualbox_version_file"`
@ -120,7 +119,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"format": &hcldec.AttrSpec{Name: "format", Type: cty.String, Required: false},
"export_opts": &hcldec.AttrSpec{Name: "export_opts", Type: cty.List(cty.String), Required: false},
"output_directory": &hcldec.AttrSpec{Name: "output_directory", Type: cty.String, Required: false},

View File

@ -29,12 +29,11 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
DisableVNC *bool `mapstructure:"disable_vnc" cty:"disable_vnc"`
RawBootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
BootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
FusionAppPath *string `mapstructure:"fusion_app_path" required:"false" cty:"fusion_app_path"`
RemoteType *string `mapstructure:"remote_type" required:"false" cty:"remote_type"`
RemoteDatastore *string `mapstructure:"remote_datastore" required:"false" cty:"remote_datastore"`
@ -62,7 +61,7 @@ type FlatConfig struct {
VNCPortMax *int `mapstructure:"vnc_port_max" cty:"vnc_port_max"`
VNCDisablePassword *bool `mapstructure:"vnc_disable_password" required:"false" cty:"vnc_disable_password"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -161,7 +160,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"disable_vnc": &hcldec.AttrSpec{Name: "disable_vnc", Type: cty.Bool, Required: false},
"boot_key_interval": &hcldec.AttrSpec{Name: "boot_key_interval", Type: cty.String, Required: false},
"fusion_app_path": &hcldec.AttrSpec{Name: "fusion_app_path", Type: cty.String, Required: false},

View File

@ -22,12 +22,11 @@ type FlatConfig struct {
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
RawBootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
RawBootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootGroupInterval *string `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootGroupInterval *string `cty:"boot_group_interval"`
DisableVNC *bool `mapstructure:"disable_vnc" cty:"disable_vnc"`
RawBootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
BootKeyInterval *string `mapstructure:"boot_key_interval" cty:"boot_key_interval"`
FusionAppPath *string `mapstructure:"fusion_app_path" required:"false" cty:"fusion_app_path"`
RemoteType *string `mapstructure:"remote_type" required:"false" cty:"remote_type"`
RemoteDatastore *string `mapstructure:"remote_datastore" required:"false" cty:"remote_datastore"`
@ -46,7 +45,7 @@ type FlatConfig struct {
VNCPortMax *int `mapstructure:"vnc_port_max" cty:"vnc_port_max"`
VNCDisablePassword *bool `mapstructure:"vnc_disable_password" required:"false" cty:"vnc_disable_password"`
ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"`
RawShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"`
Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
@ -130,7 +129,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"boot_keygroup_interval": &hcldec.AttrSpec{Name: "boot_keygroup_interval", Type: cty.String, Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_group_interval": &hcldec.AttrSpec{Name: "boot_group_interval", Type: cty.String, Required: false},
"disable_vnc": &hcldec.AttrSpec{Name: "disable_vnc", Type: cty.Bool, Required: false},
"boot_key_interval": &hcldec.AttrSpec{Name: "boot_key_interval", Type: cty.String, Required: false},
"fusion_app_path": &hcldec.AttrSpec{Name: "fusion_app_path", Type: cty.String, Required: false},

View File

@ -111,6 +111,10 @@ func main() {
}
fieldType := string(b[field.Type.Pos()-1 : field.Type.End()-1])
fieldType = strings.ReplaceAll(fieldType, "*", `\*`)
switch fieldType {
case "time.Duration":
fieldType = `duration string | ex: "1h5m2s"`
}
field := Field{
Name: name,

View File

@ -112,21 +112,19 @@ type BootConfig struct {
// Packer to wait five seconds and one minute 30 seconds, respectively. If
// this isn't specified, a sensible default value is picked depending on
// the builder type.
RawBootGroupInterval string `mapstructure:"boot_keygroup_interval"`
BootGroupInterval time.Duration `mapstructure:"boot_keygroup_interval"`
// The time to wait after booting the initial virtual machine before typing
// the `boot_command`. The value of this should be a duration. Examples are
// `5s` and `1m30s` which will cause Packer to wait five seconds and one
// minute 30 seconds, respectively. If this isn't specified, the default is
// `10s` or 10 seconds.
RawBootWait string `mapstructure:"boot_wait"`
BootWait time.Duration `mapstructure:"boot_wait"`
// This is an array of commands to type when the virtual machine is first
// booted. The goal of these commands should be to type just enough to
// initialize the operating system installer. Special keys can be typed as
// well, and are covered in the section below on the boot command. If this
// is not specified, it is assumed the installer will start itself.
BootCommand []string `mapstructure:"boot_command"`
BootGroupInterval time.Duration ``
BootWait time.Duration ``
BootCommand []string `mapstructure:"boot_command"`
}
// The boot command "typed" character for character over a VNC connection to
@ -142,37 +140,12 @@ type VNCConfig struct {
// when this is true. Defaults to false.
DisableVNC bool `mapstructure:"disable_vnc"`
// Time in ms to wait between each key press
RawBootKeyInterval string `mapstructure:"boot_key_interval"`
BootKeyInterval time.Duration ``
BootKeyInterval time.Duration `mapstructure:"boot_key_interval"`
}
func (c *BootConfig) Prepare(ctx *interpolate.Context) (errs []error) {
if c.RawBootWait == "" {
c.RawBootWait = "10s"
}
if c.RawBootWait != "" {
bw, err := time.ParseDuration(c.RawBootWait)
if err != nil {
errs = append(
errs, fmt.Errorf("Failed parsing boot_wait: %s", err))
} else {
c.BootWait = bw
}
}
if c.RawBootGroupInterval == "" {
c.RawBootGroupInterval = "0ms"
}
if c.RawBootGroupInterval != "" {
bgi, err := time.ParseDuration(c.RawBootGroupInterval)
if err != nil {
errs = append(
errs, fmt.Errorf("Failed parsing boot_keygroup_interval: %s", err))
} else {
c.BootGroupInterval = bgi
}
if c.BootWait == 0 {
c.BootWait = 10 * time.Second
}
if c.BootCommand != nil {
@ -197,20 +170,6 @@ func (c *VNCConfig) Prepare(ctx *interpolate.Context) (errs []error) {
fmt.Errorf("A boot command cannot be used when vnc is disabled."))
}
if c.RawBootKeyInterval == "" {
c.RawBootKeyInterval = "0ms"
}
if c.RawBootKeyInterval != "" {
bki, err := time.ParseDuration(c.RawBootKeyInterval)
if err != nil {
errs = append(
errs, fmt.Errorf("Failed parsing boot_key_interval: %s", err))
} else {
c.BootKeyInterval = bki
}
}
errs = append(errs, c.BootConfig.Prepare(ctx)...)
return
}

View File

@ -2,6 +2,7 @@ package bootcommand
import (
"testing"
"time"
"github.com/hashicorp/packer/template/interpolate"
)
@ -11,26 +12,18 @@ func TestConfigPrepare(t *testing.T) {
// Test a default boot_wait
c = new(BootConfig)
c.RawBootWait = ""
c.BootWait = 0
errs := c.Prepare(&interpolate.Context{})
if len(errs) > 0 {
t.Fatalf("bad: %#v", errs)
}
if c.RawBootWait != "10s" {
t.Fatalf("bad value: %s", c.RawBootWait)
}
// Test with a bad boot_wait
c = new(BootConfig)
c.RawBootWait = "this is not good"
errs = c.Prepare(&interpolate.Context{})
if len(errs) == 0 {
t.Fatal("should error")
if c.BootWait != 10*time.Second {
t.Fatalf("bad value: %s", c.BootWait)
}
// Test with a good one
c = new(BootConfig)
c.RawBootWait = "5s"
c.BootWait = 5 * time.Second
errs = c.Prepare(&interpolate.Context{})
if len(errs) > 0 {
t.Fatalf("bad: %#v", errs)

View File

@ -3,7 +3,6 @@
package shutdowncommand
import (
"fmt"
"time"
"github.com/hashicorp/packer/template/interpolate"
@ -23,22 +22,13 @@ type ShutdownConfig struct {
// 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).
RawShutdownTimeout string `mapstructure:"shutdown_timeout" required:"false"`
ShutdownTimeout time.Duration ``
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" required:"false"`
}
func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error {
if c.RawShutdownTimeout == "" {
c.RawShutdownTimeout = "5m"
if c.ShutdownTimeout == 0 {
c.ShutdownTimeout = 5 * time.Minute
}
var errs []error
var err error
c.ShutdownTimeout, err = time.ParseDuration(c.RawShutdownTimeout)
if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err))
}
return errs
return nil
}

View File

@ -26,17 +26,9 @@ func TestShutdownConfigPrepare_ShutdownTimeout(t *testing.T) {
var c *ShutdownConfig
var errs []error
// Test with a bad value
c = testShutdownConfig()
c.RawShutdownTimeout = "this is not good"
errs = c.Prepare(interpolate.NewContext())
if len(errs) == 0 {
t.Fatalf("should have error")
}
// Test with a good one
c = testShutdownConfig()
c.RawShutdownTimeout = "5s"
c.ShutdownTimeout = 5 * time.Second
errs = c.Prepare(interpolate.NewContext())
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)

View File

@ -80,7 +80,7 @@ func TestParser_ParseFile(t *testing.T) {
RawSingleISOUrl: strPtr("http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso"),
BootCommand: []string{"..."},
ShutdownCommand: strPtr("echo 'vagrant' | sudo -S shutdown -P now"),
RawBootWait: strPtr("10s"),
BootWait: strPtr("10s"),
VBoxManage: [][]string{},
VBoxManagePost: [][]string{},
},

View File

@ -52,7 +52,7 @@ func TestParser_Parse(t *testing.T) {
RawSingleISOUrl: strPtr("http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso"),
BootCommand: []string{"..."},
ShutdownCommand: strPtr("echo 'vagrant' | sudo -S shutdown -P now"),
RawBootWait: strPtr("10s"),
BootWait: strPtr("10s"),
VBoxManage: [][]string{},
VBoxManagePost: [][]string{},
},

View File

@ -470,7 +470,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
return errs
}
func (c *Config) prepareWinRM(ctx *interpolate.Context) []error {
func (c *Config) prepareWinRM(ctx *interpolate.Context) (errs []error) {
if c.WinRMPort == 0 && c.WinRMUseSSL {
c.WinRMPort = 5986
} else if c.WinRMPort == 0 {
@ -485,7 +485,6 @@ func (c *Config) prepareWinRM(ctx *interpolate.Context) []error {
c.WinRMTransportDecorator = func() winrm.Transporter { return &winrm.ClientNTLM{} }
}
var errs []error
if c.WinRMUser == "" {
errs = append(errs, errors.New("winrm_username must be specified."))
}

View File

@ -135,12 +135,12 @@ func (c *Core) generateCoreBuildProvisioner(rawP *template.Provisioner, rawName
}
}
// If we're pausing, we wrap the provisioner in a special pauser.
if rawP.PauseBefore > 0 {
if rawP.PauseBefore != 0 {
provisioner = &PausedProvisioner{
PauseBefore: rawP.PauseBefore,
Provisioner: provisioner,
}
} else if rawP.Timeout > 0 {
} else if rawP.Timeout != 0 {
provisioner = &TimeoutProvisioner{
Timeout: rawP.Timeout,
Provisioner: provisioner,

View File

@ -35,16 +35,17 @@ type Config struct {
SpacesKey string `mapstructure:"spaces_key"`
SpacesSecret string `mapstructure:"spaces_secret"`
SpacesRegion string `mapstructure:"spaces_region"`
SpaceName string `mapstructure:"space_name"`
ObjectName string `mapstructure:"space_object_name"`
SkipClean bool `mapstructure:"skip_clean"`
Tags []string `mapstructure:"image_tags"`
Name string `mapstructure:"image_name"`
Description string `mapstructure:"image_description"`
Distribution string `mapstructure:"image_distribution"`
ImageRegions []string `mapstructure:"image_regions"`
Timeout time.Duration `mapstructure:"timeout"`
SpacesRegion string `mapstructure:"spaces_region"`
SpaceName string `mapstructure:"space_name"`
ObjectName string `mapstructure:"space_object_name"`
SkipClean bool `mapstructure:"skip_clean"`
Tags []string `mapstructure:"image_tags"`
Name string `mapstructure:"image_name"`
Description string `mapstructure:"image_description"`
Distribution string `mapstructure:"image_distribution"`
ImageRegions []string `mapstructure:"image_regions"`
Timeout time.Duration `mapstructure:"timeout"`
ctx interpolate.Context
}

View File

@ -6,6 +6,7 @@ import (
"context"
"fmt"
"strings"
"time"
"github.com/hashicorp/packer/builder/googlecompute"
"github.com/hashicorp/packer/common"
@ -138,7 +139,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
Metadata: exporterMetadata,
Network: p.config.Network,
NetworkProjectId: builderProjectId,
RawStateTimeout: "5m",
StateTimeout: 5 * time.Minute,
SourceImageFamily: "debian-9-worker",
SourceImageProjectId: "compute-image-tools",
Subnetwork: p.config.Subnetwork,
@ -149,7 +150,6 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
"https://www.googleapis.com/auth/userinfo.email",
},
}
exporterConfig.CalcTimeout()
driver, err := googlecompute.NewDriverGCE(ui, builderProjectId,
p.config.account, p.config.VaultGCPOauthEngine)

View File

@ -510,7 +510,7 @@ func TestProvisionerProvision_UploadFails(t *testing.T) {
p := new(Provisioner)
comm := new(packer.ScriptUploadErrorMockCommunicator)
p.Prepare(config)
p.config.StartRetryTimeout = time.Second
p.config.StartRetryTimeout = 1 * time.Second
err := p.Provision(context.Background(), ui, comm)
if !strings.Contains(err.Error(), packer.ScriptUploadErrorMockCommunicatorError.Error()) {
t.Fatalf("expected Provision() error %q to contain %q",

View File

@ -33,9 +33,7 @@ type Config struct {
InlineShebang string `mapstructure:"inline_shebang"`
// A duration of how long to pause after the provisioner
RawPauseAfter string `mapstructure:"pause_after"`
PauseAfter time.Duration
PauseAfter time.Duration `mapstructure:"pause_after"`
// Write the Vars to a file and source them from there rather than declaring
// inline
@ -52,15 +50,14 @@ type Config struct {
// The timeout for retrying to start the process. Until this timeout
// is reached, if the provisioner can't start a process, it retries.
// This can be set high to allow for reboots.
RawStartRetryTimeout string `mapstructure:"start_retry_timeout"`
StartRetryTimeout time.Duration `mapstructure:"start_retry_timeout"`
// Whether to clean scripts up
SkipClean bool `mapstructure:"skip_clean"`
ExpectDisconnect bool `mapstructure:"expect_disconnect"`
startRetryTimeout time.Duration
ctx interpolate.Context
ctx interpolate.Context
// name of the tmp environment variable file, if UseEnvVarFile is true
envVarFile string
}
@ -104,8 +101,8 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p.config.InlineShebang = "/bin/sh -e"
}
if p.config.RawStartRetryTimeout == "" {
p.config.RawStartRetryTimeout = "5m"
if p.config.StartRetryTimeout == 0 {
p.config.StartRetryTimeout = 5 * time.Minute
}
if p.config.RemoteFolder == "" {
@ -163,22 +160,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
}
if p.config.RawStartRetryTimeout != "" {
p.config.startRetryTimeout, err = time.ParseDuration(p.config.RawStartRetryTimeout)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Failed parsing start_retry_timeout: %s", err))
}
}
if p.config.RawPauseAfter != "" {
p.config.PauseAfter, err = time.ParseDuration(p.config.RawPauseAfter)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Failed parsing pause_after: %s", err))
}
}
if errs != nil && len(errs.Errors) > 0 {
return errs
}
@ -240,7 +221,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C
// upload the var file
var cmd *packer.RemoteCmd
err = retry.Config{StartTimeout: p.config.startRetryTimeout}.Run(ctx, func(ctx context.Context) error {
err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error {
if _, err := tf.Seek(0, 0); err != nil {
return err
}
@ -303,7 +284,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C
// and then the command is executed but the file doesn't exist
// any longer.
var cmd *packer.RemoteCmd
err = retry.Config{StartTimeout: p.config.startRetryTimeout}.Run(ctx, func(ctx context.Context) error {
err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error {
if _, err := f.Seek(0, 0); err != nil {
return err
}
@ -365,7 +346,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C
}
}
if p.config.RawPauseAfter != "" {
if p.config.PauseAfter != 0 {
ui.Say(fmt.Sprintf("Pausing %s after this provisioner...", p.config.PauseAfter))
select {
case <-time.After(p.config.PauseAfter):
@ -378,7 +359,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C
func (p *Provisioner) cleanupRemoteFile(path string, comm packer.Communicator) error {
ctx := context.TODO()
err := retry.Config{StartTimeout: p.config.startRetryTimeout}.Run(ctx, func(ctx context.Context) error {
err := retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error {
cmd := &packer.RemoteCmd{
Command: fmt.Sprintf("rm -f %s", path),
}

View File

@ -9,29 +9,29 @@ import (
// FlatConfig is an auto-generated flat version of Config.
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatConfig struct {
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
Binary *bool `cty:"binary"`
ExecuteCommand *string `mapstructure:"execute_command" cty:"execute_command"`
Inline []string `cty:"inline"`
RemotePath *string `mapstructure:"remote_path" cty:"remote_path"`
Script *string `cty:"script"`
Scripts []string `cty:"scripts"`
ValidExitCodes []int `mapstructure:"valid_exit_codes" cty:"valid_exit_codes"`
Vars []string `mapstructure:"environment_vars" cty:"environment_vars"`
InlineShebang *string `mapstructure:"inline_shebang" cty:"inline_shebang"`
RawPauseAfter *string `mapstructure:"pause_after" cty:"pause_after"`
UseEnvVarFile *bool `mapstructure:"use_env_var_file" cty:"use_env_var_file"`
RemoteFolder *string `mapstructure:"remote_folder" cty:"remote_folder"`
RemoteFile *string `mapstructure:"remote_file" cty:"remote_file"`
RawStartRetryTimeout *string `mapstructure:"start_retry_timeout" cty:"start_retry_timeout"`
SkipClean *bool `mapstructure:"skip_clean" cty:"skip_clean"`
ExpectDisconnect *bool `mapstructure:"expect_disconnect" cty:"expect_disconnect"`
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
Binary *bool `cty:"binary"`
ExecuteCommand *string `mapstructure:"execute_command" cty:"execute_command"`
Inline []string `cty:"inline"`
RemotePath *string `mapstructure:"remote_path" cty:"remote_path"`
Script *string `cty:"script"`
Scripts []string `cty:"scripts"`
ValidExitCodes []int `mapstructure:"valid_exit_codes" cty:"valid_exit_codes"`
Vars []string `mapstructure:"environment_vars" cty:"environment_vars"`
InlineShebang *string `mapstructure:"inline_shebang" cty:"inline_shebang"`
PauseAfter *string `mapstructure:"pause_after" cty:"pause_after"`
UseEnvVarFile *bool `mapstructure:"use_env_var_file" cty:"use_env_var_file"`
RemoteFolder *string `mapstructure:"remote_folder" cty:"remote_folder"`
RemoteFile *string `mapstructure:"remote_file" cty:"remote_file"`
StartRetryTimeout *string `mapstructure:"start_retry_timeout" cty:"start_retry_timeout"`
SkipClean *bool `mapstructure:"skip_clean" cty:"skip_clean"`
ExpectDisconnect *bool `mapstructure:"expect_disconnect" cty:"expect_disconnect"`
}
// FlatMapstructure returns a new FlatConfig.

View File

@ -40,8 +40,8 @@ func TestProvisioner_Provision(t *testing.T) {
args args
wantErr bool
}{
{"valid sleep", fields{time.Millisecond}, args{context.Background()}, false},
{"timeout", fields{time.Millisecond}, args{ctxCancelled}, true},
{"valid sleep", fields{1 * time.Millisecond}, args{context.Background()}, false},
{"timeout", fields{1 * time.Millisecond}, args{ctxCancelled}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

View File

@ -279,7 +279,7 @@
subnet_id to be set. If this field is left blank, Packer will try to get
the VPC ID from the subnet_id.
- `windows_password_timeout` (time.Duration) - The timeout for waiting for a Windows
- `windows_password_timeout` (duration string | ex: "1h5m2s") - The timeout for waiting for a Windows
password for Windows instances. Defaults to 20 minutes. Example value:
10m

View File

@ -34,7 +34,7 @@
"managed_image_name": "TargetImageName",
"managed_image_resource_group_name": "TargetResourceGroup"
- `shared_image_gallery_timeout` (time.Duration) - How long to wait for an image to be published to the shared image
- `shared_image_gallery_timeout` (duration string | ex: "1h5m2s") - How long to wait for an image to be published to the shared image
gallery before timing out. If your Packer build is failing on the
Publishing to Shared Image Gallery step with the error `Original Error:
context deadline exceeded`, but the image is present when you check your
@ -187,7 +187,7 @@
3. PlanPublisher
4. PlanPromotionCode
- `polling_duration_timeout` (time.Duration) - The default PollingDuration for azure is 15mins, this property will override
- `polling_duration_timeout` (duration string | ex: "1h5m2s") - The default PollingDuration for azure is 15mins, this property will override
that value. See [Azure DefaultPollingDuration](https://godoc.org/github.com/Azure/go-autorest/autorest#pkg-constants)
If your Packer build is failing on the
ARM deployment step with the error `Original Error:

View File

@ -1,6 +1,6 @@
<!-- Code generated from the comments of the Config struct in builder/cloudstack/config.go; DO NOT EDIT MANUALLY -->
- `async_timeout` (time.Duration) - The time duration to wait for async calls to
- `async_timeout` (duration string | ex: "1h5m2s") - The time duration to wait for async calls to
finish. Defaults to 30m.
- `http_get_only` (bool) - Some cloud providers only allow HTTP GET calls
@ -32,7 +32,7 @@
attached to a virtual machine. Defaults to `false`. This option is only
available when using `source_iso`.
- `eject_iso_delay` (time.Duration) - Configure the duration time to wait, making sure virtual machine is able
- `eject_iso_delay` (duration string | ex: "1h5m2s") - Configure the duration time to wait, making sure virtual machine is able
to finish installing OS before it ejects safely. Requires `eject_iso`
set to `true` and this option is only available when using `source_iso`.

View File

@ -20,11 +20,11 @@
- `snapshot_regions` ([]string) - The regions of the resulting
snapshot that will appear in your account.
- `state_timeout` (time.Duration) - The time to wait, as a duration string, for a
- `state_timeout` (duration string | ex: "1h5m2s") - The time to wait, as a duration string, for a
droplet to enter a desired state (such as "active") before timing out. The
default state timeout is "6m".
- `snapshot_timeout` (time.Duration) - How long to wait for an image to be published to the shared image
- `snapshot_timeout` (duration string | ex: "1h5m2s") - How long to wait for an image to be published to the shared image
gallery before timing out. If your Packer build is failing on the
Publishing to Shared Image Gallery step with the error `Original Error:
context deadline exceeded`, but the image is present when you check your

View File

@ -88,7 +88,7 @@
- `preemptible` (bool) - If true, launch a preemptible instance.
- `state_timeout` (string) - The time to wait for instance state changes. Defaults to "5m".
- `state_timeout` (duration string | ex: "1h5m2s") - The time to wait for instance state changes. Defaults to "5m".
- `region` (string) - The region in which to launch the instance. Defaults to the region
hosting the specified zone.

View File

@ -6,7 +6,7 @@
- `token_login` (string) - Login (an e-mail) on HyperOne platform. Set this
if you want to fetch the token by SSH authentication.
- `state_timeout` (time.Duration) - Timeout for waiting on the API to complete
- `state_timeout` (duration string | ex: "1h5m2s") - Timeout for waiting on the API to complete
a request. Defaults to 5m.
- `image_name` (string) - The name of the resulting image. Defaults to

View File

@ -11,7 +11,7 @@
as ssh so you can execute packer builds on a remote host. Defaults to
Empty.
- `init_timeout` (string) - The timeout in seconds to wait for the the
- `init_timeout` (duration string | ex: "1h5m2s") - The timeout in seconds to wait for the the
container to start. Defaults to 20 seconds.
- `create_options` ([]string) - Options to pass to lxc-create. For

View File

@ -8,12 +8,12 @@
since reboots may fail and specify the final shutdown command in your
last script.
- `shutdown_timeout` (string) - The amount of time to wait after executing the
- `shutdown_timeout` (duration string | ex: "1h5m2s") - The amount of time to wait after executing the
shutdown_command for the virtual machine to actually shut down. If it
doesn't shut down in this time, it is an error. By default, the timeout is
5m or five minutes.
- `post_shutdown_delay` (string) - The amount of time to wait after shutting
- `post_shutdown_delay` (duration string | ex: "1h5m2s") - The amount of time to wait after shutting
down the virtual machine. If you get the error
Error removing floppy controller, you might need to set this to 5m
or so. By default, the delay is 0s or disabled.

View File

@ -73,6 +73,6 @@
- `zone` (string) - The name of the zone to launch the instance. This defaults to `ru-central1-a`.
- `state_timeout` (time.Duration) - The time to wait for instance state changes.
- `state_timeout` (duration string | ex: "1h5m2s") - The time to wait for instance state changes.
Defaults to `5m`.

View File

@ -1,12 +1,12 @@
<!-- Code generated from the comments of the BootConfig struct in common/bootcommand/config.go; DO NOT EDIT MANUALLY -->
- `boot_keygroup_interval` (string) - Time to wait after sending a group of key pressses. The value of this
- `boot_keygroup_interval` (duration string | ex: "1h5m2s") - Time to wait after sending a group of key pressses. The value of this
should be a duration. Examples are `5s` and `1m30s` which will cause
Packer to wait five seconds and one minute 30 seconds, respectively. If
this isn't specified, a sensible default value is picked depending on
the builder type.
- `boot_wait` (string) - The time to wait after booting the initial virtual machine before typing
- `boot_wait` (duration string | ex: "1h5m2s") - The time to wait after booting the initial virtual machine before typing
the `boot_command`. The value of this should be a duration. Examples are
`5s` and `1m30s` which will cause Packer to wait five seconds and one
minute 30 seconds, respectively. If this isn't specified, the default is

View File

@ -3,5 +3,5 @@
- `disable_vnc` (bool) - Whether to create a VNC connection or not. A boot_command cannot be used
when this is true. Defaults to false.
- `boot_key_interval` (string) - Time in ms to wait between each key press
- `boot_key_interval` (duration string | ex: "1h5m2s") - Time in ms to wait between each key press

View File

@ -9,7 +9,7 @@
reboots may fail) and instead specify the final shutdown command in your
last script.
- `shutdown_timeout` (string) - The amount of time to wait after executing the shutdown_command for the
- `shutdown_timeout` (duration string | ex: "1h5m2s") - 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).

View File

@ -15,7 +15,7 @@
that uses `docker exec` and `docker cp` to execute scripts and copy
files.
- `pause_before_connecting` (time.Duration) - We recommend that you enable SSH or WinRM as the very last step in your
- `pause_before_connecting` (duration string | ex: "1h5m2s") - We recommend that you enable SSH or WinRM as the very last step in your
guest's bootstrap script, but sometimes you may have a race condition where
you need Packer to wait before attempting to connect to your guest.

View File

@ -36,7 +36,7 @@
- `ssh_pty` (bool) - If `true`, a PTY will be requested for the SSH connection. This defaults
to `false`.
- `ssh_timeout` (time.Duration) - The time to wait for SSH to become available. Packer uses this to
- `ssh_timeout` (duration string | ex: "1h5m2s") - The time to wait for SSH to become available. Packer uses this to
determine when the machine has booted so this is usually quite long.
Example value: `10m`.
@ -79,10 +79,10 @@
- `ssh_proxy_password` (string) - The optional password to use to authenticate with the proxy server.
- `ssh_keep_alive_interval` (time.Duration) - How often to send "keep alive" messages to the server. Set to a negative
- `ssh_keep_alive_interval` (duration string | ex: "1h5m2s") - How often to send "keep alive" messages to the server. Set to a negative
value (`-1s`) to disable. Example value: `10s`. Defaults to `5s`.
- `ssh_read_write_timeout` (time.Duration) - The amount of time to wait for a remote command to end. This might be
- `ssh_read_write_timeout` (duration string | ex: "1h5m2s") - The amount of time to wait for a remote command to end. This might be
useful if, for example, packer hangs on a connection after a reboot.
Example: `5m`. Disabled by default.

View File

@ -14,7 +14,7 @@
unencrypted connection and `5986` for SSL when `winrm_use_ssl` is set to
true.
- `winrm_timeout` (time.Duration) - The amount of time to wait for WinRM to become available. This defaults
- `winrm_timeout` (duration string | ex: "1h5m2s") - The amount of time to wait for WinRM to become available. This defaults
to `30m` since setting up a Windows machine generally takes a long time.
- `winrm_use_ssl` (bool) - If `true`, use HTTPS for WinRM.