2013-12-24 01:27:01 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/helper/communicator"
|
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2013-12-24 01:27:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type SSHConfig struct {
|
2015-06-13 18:52:44 -04:00
|
|
|
Comm communicator.Config `mapstructure:",squash"`
|
2013-12-24 01:27:01 -05:00
|
|
|
|
2015-06-13 18:52:44 -04:00
|
|
|
// These are deprecated, but we keep them around for BC
|
|
|
|
// TODO(@mitchellh): remove
|
|
|
|
SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"`
|
|
|
|
SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"`
|
2013-12-24 01:27:01 -05:00
|
|
|
}
|
|
|
|
|
2015-05-27 17:16:28 -04:00
|
|
|
func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error {
|
2015-06-13 18:52:44 -04:00
|
|
|
// TODO: backwards compatibility, write fixer instead
|
|
|
|
if c.SSHWaitTimeout != 0 {
|
|
|
|
c.Comm.SSHTimeout = c.SSHWaitTimeout
|
2013-12-24 01:27:01 -05:00
|
|
|
}
|
2015-06-13 18:52:44 -04:00
|
|
|
if c.SSHSkipRequestPty {
|
|
|
|
c.Comm.SSHPty = false
|
2013-12-24 01:27:01 -05:00
|
|
|
}
|
|
|
|
|
2015-06-13 18:52:44 -04:00
|
|
|
return c.Comm.Prepare(ctx)
|
2013-12-24 01:27:01 -05:00
|
|
|
}
|