packer-cn/builder/vmware/common/ssh_config.go

34 lines
845 B
Go
Raw Normal View History

2013-12-24 01:27:01 -05:00
package common
import (
"time"
2015-06-13 18:52:44 -04:00
"github.com/mitchellh/packer/helper/communicator"
2015-05-27 17:16:28 -04:00
"github.com/mitchellh/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
SSHKeyPath string `mapstructure:"ssh_key_path"`
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
2013-12-24 01:27:01 -05:00
if c.SSHKeyPath != "" {
2015-06-13 18:52:44 -04:00
c.Comm.SSHPrivateKey = c.SSHKeyPath
2013-12-24 01:27:01 -05:00
}
2015-06-13 18:52:44 -04:00
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
}