github.com/emate/packer@v0.8.1-0.20150625195101-fe0fde195dc6/builder/vmware/common/ssh_config.go (about)

     1  package common
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/mitchellh/packer/helper/communicator"
     7  	"github.com/mitchellh/packer/template/interpolate"
     8  )
     9  
    10  type SSHConfig struct {
    11  	Comm communicator.Config `mapstructure:",squash"`
    12  
    13  	// These are deprecated, but we keep them around for BC
    14  	// TODO(@mitchellh): remove
    15  	SSHKeyPath        string        `mapstructure:"ssh_key_path"`
    16  	SSHSkipRequestPty bool          `mapstructure:"ssh_skip_request_pty"`
    17  	SSHWaitTimeout    time.Duration `mapstructure:"ssh_wait_timeout"`
    18  }
    19  
    20  func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error {
    21  	// TODO: backwards compatibility, write fixer instead
    22  	if c.SSHKeyPath != "" {
    23  		c.Comm.SSHPrivateKey = c.SSHKeyPath
    24  	}
    25  	if c.SSHWaitTimeout != 0 {
    26  		c.Comm.SSHTimeout = c.SSHWaitTimeout
    27  	}
    28  	if c.SSHSkipRequestPty {
    29  		c.Comm.SSHPty = false
    30  	}
    31  
    32  	return c.Comm.Prepare(ctx)
    33  }