Skip to content

Commit b0dceef

Browse files
committed
use path.join instead of filepath.join for ssh copy
1 parent e6da47f commit b0dceef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/minikube/bootstrapper/ssh_runner.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package bootstrapper
1919
import (
2020
"fmt"
2121
"io"
22-
"path/filepath"
22+
"path"
23+
goruntime "runtime"
24+
"strings"
2325
"sync"
2426

2527
"github.com/golang/glog"
@@ -81,7 +83,7 @@ func (s *SSHRunner) CombinedOutput(cmd string) (string, error) {
8183

8284
// Copy copies a file to the remote over SSH.
8385
func (s *SSHRunner) Copy(f assets.CopyableFile) error {
84-
deleteCmd := fmt.Sprintf("sudo rm -f %s", filepath.Join(f.GetTargetDir(), f.GetTargetName()))
86+
deleteCmd := fmt.Sprintf("sudo rm -f %s", path.Join(f.GetTargetDir(), f.GetTargetName()))
8587
mkdirCmd := fmt.Sprintf("sudo mkdir -p %s", f.GetTargetDir())
8688
for _, cmd := range []string{deleteCmd, mkdirCmd} {
8789
if err := s.Run(cmd); err != nil {
@@ -111,7 +113,11 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
111113
fmt.Fprint(w, "\x00")
112114
}()
113115

114-
scpcmd := fmt.Sprintf("sudo scp -t %s", f.GetTargetDir())
116+
targetDir := f.GetTargetDir()
117+
if goruntime.GOOS == "windows" {
118+
targetDir = strings.Replace(f.GetTargetDir(), "\\", "/", -1)
119+
}
120+
scpcmd := fmt.Sprintf("sudo scp -t %s", targetDir)
115121
if err := sess.Run(scpcmd); err != nil {
116122
return errors.Wrapf(err, "Error running scp command: %s", scpcmd)
117123
}

0 commit comments

Comments
 (0)