builder/amazonebs: Don't export sshTimeout so it can't be set

This commit is contained in:
Mitchell Hashimoto 2013-07-14 21:18:18 +09:00
parent 07449a7801
commit 51206a491b
2 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,6 @@ type config struct {
InstanceType string `mapstructure:"instance_type"` InstanceType string `mapstructure:"instance_type"`
SSHUsername string `mapstructure:"ssh_username"` SSHUsername string `mapstructure:"ssh_username"`
SSHPort int `mapstructure:"ssh_port"` SSHPort int `mapstructure:"ssh_port"`
SSHTimeout time.Duration
SecurityGroupId string `mapstructure:"security_group_id"` SecurityGroupId string `mapstructure:"security_group_id"`
// Configuration of the resulting AMI // Configuration of the resulting AMI
@ -43,6 +42,9 @@ type config struct {
PackerDebug bool `mapstructure:"packer_debug"` PackerDebug bool `mapstructure:"packer_debug"`
RawSSHTimeout string `mapstructure:"ssh_timeout"` RawSSHTimeout string `mapstructure:"ssh_timeout"`
// Unexported fields that are calculated from others
sshTimeout time.Duration
} }
type Builder struct { type Builder struct {
@ -110,7 +112,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs = append(errs, errors.New("An ssh_username must be specified")) errs = append(errs, errors.New("An ssh_username must be specified"))
} }
b.config.SSHTimeout, err = time.ParseDuration(b.config.RawSSHTimeout) b.config.sshTimeout, err = time.ParseDuration(b.config.RawSSHTimeout)
if err != nil { if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing ssh_timeout: %s", err)) errs = append(errs, fmt.Errorf("Failed parsing ssh_timeout: %s", err))
} }

View File

@ -30,9 +30,9 @@ func (s *stepConnectSSH) Run(state map[string]interface{}) multistep.StepAction
waitDone <- true waitDone <- true
}() }()
log.Printf("Waiting for SSH, up to timeout: %s", config.SSHTimeout.String()) log.Printf("Waiting for SSH, up to timeout: %s", config.sshTimeout.String())
timeout := time.After(config.SSHTimeout) timeout := time.After(config.sshTimeout)
WaitLoop: WaitLoop:
for { for {
// Wait for either SSH to become available, a timeout to occur, // Wait for either SSH to become available, a timeout to occur,