Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update communicator.go #162

Merged
merged 2 commits into from
Aug 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions helper/ssh/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type Config struct {
NoPty bool
}

// Creates a new packer.Communicator implementation over SSH. This takes
// New creates a new packer.Communicator implementation over SSH. This takes
// an already existing TCP connection and SSH configuration.
func New(address string, config *Config) (result *SSHCommunicator, err error) {
// Establish an initial connection and connect
Expand Down Expand Up @@ -182,19 +182,19 @@ func (c *SSHCommunicator) Start(cmd *RemoteCmd) (err error) {

func (c *SSHCommunicator) Upload(path string, input io.Reader) error {
// The target directory and file for talking the SCP protocol
target_dir := filepath.Dir(path)
target_file := filepath.Base(path)
targetDir := filepath.Dir(path)
targetFile := filepath.Base(path)

// On windows, filepath.Dir uses backslash separators (ie. "\tmp").
// This does not work when the target host is unix. Switch to forward slash
// which works for unix and windows
target_dir = filepath.ToSlash(target_dir)
targetDir = filepath.ToSlash(targetDir)

scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error {
return scpUploadFile(target_file, input, w, stdoutR)
return scpUploadFile(targetFile, input, w, stdoutR)
}

return c.scpSession("scp -vt "+target_dir, scpFunc)
return c.scpSession("scp -vt "+targetDir, scpFunc)
}

func (c *SSHCommunicator) UploadDir(dst string, src string, excl []string) error {
Expand Down