Skip to content

Commit 87d5561

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

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/minikube/bootstrapper/ssh_runner.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ package bootstrapper
1919
import (
2020
"fmt"
2121
"io"
22-
"path/filepath"
22+
"path"
23+
"strings"
2324
"sync"
2425

2526
"github.com/golang/glog"
2627
"github.com/pkg/errors"
2728
"golang.org/x/crypto/ssh"
29+
"k8s.io/apimachinery/pkg/runtime"
2830
"k8s.io/minikube/pkg/minikube/assets"
2931
)
3032

@@ -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,6 +113,10 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
111113
fmt.Fprint(w, "\x00")
112114
}()
113115

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

0 commit comments

Comments
 (0)