Skip to content

Commit

Permalink
fix: Windows<->Linux path conversion when using remote host
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Dec 19, 2023
1 parent 042374e commit e478592
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pkg/driver/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ func (d *dockerDriver) RunDockerDevContainer(

// workspace mount
if options.WorkspaceMount != nil {
args = append(args, "--mount", options.WorkspaceMount.String())
workspacePath := d.EnsurePath(options.WorkspaceMount)

args = append(args, "--mount", workspacePath.String())
}

// override container user
Expand Down Expand Up @@ -309,3 +311,22 @@ func (d *dockerDriver) RunDockerDevContainer(

return nil
}

func (d *dockerDriver) EnsurePath(path *config.Mount) *config.Mount {
// in case of local windows and remote linux tcp, we need to manually do the path conversion
if runtime.GOOS == "windows" {
for _, v := range d.Docker.Environment {
if strings.Contains(v, "DOCKER_HOST=tcp://") {

Check failure on line 319 in pkg/driver/docker/docker.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

unixPath := path.Source
unixPath = strings.Replace(unixPath, "C:", "c", 1)
unixPath = strings.ReplaceAll(unixPath, "\\", "/")
unixPath = "/mnt/" + unixPath

path.Source = unixPath
fmt.Fprintf(os.Stderr, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA %s", unixPath)
}
}
}
return path
}

0 comments on commit e478592

Please sign in to comment.