Skip to content

Commit e0e35ac

Browse files
author
gy2006
committed
fix plugin path in win
1 parent 7e70655 commit e0e35ac

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

executor/docker.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/docker/docker/client"
1414
"github/flowci/flow-agent-x/domain"
1515
"github/flowci/flow-agent-x/util"
16-
"runtime"
1716
"strings"
1817
"time"
1918
)
@@ -355,7 +354,7 @@ func (d *dockerExecutor) initConfig() {
355354
}
356355

357356
// mount docker dock if exit or running on windows
358-
if util.IsFileExists(dockerSock) || runtime.GOOS == util.OSWin {
357+
if util.IsFileExists(dockerSock) || util.IsWindows() {
359358
binds = append(binds, fmt.Sprintf("%s:%s", dockerSock, dockerSock))
360359
}
361360

executor/docker_util.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ func tarArchiveFromPath(path string) (io.Reader, error) {
103103
header, err := tar.FileInfoHeader(fi, fi.Name())
104104
util.PanicIfErr(err)
105105

106-
header.Name = strings.TrimPrefix(strings.Replace(file, dir, "", -1), string(filepath.Separator))
106+
relativeDir := strings.Replace(file, dir, "", -1)
107+
header.Name = strings.TrimPrefix(relativeDir, string(filepath.Separator))
108+
109+
// convert path to linux path
110+
if util.IsWindows() {
111+
header.Name = strings.ReplaceAll(header.Name, util.WinPathSeparator, util.UnixPathSeparator)
112+
}
113+
107114
err = tw.WriteHeader(header)
108115
util.PanicIfErr(err)
109116

util/common.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
)
1212

1313
const (
14-
UnixNewLine = "\n"
15-
WinNewLine = "\r\n"
14+
UnixNewLine = "\n"
15+
UnixPathSeparator = "/"
16+
17+
WinNewLine = "\r\n"
18+
WinPathSeparator = "\\"
1619

1720
LineBreak = '\n'
1821
EmptyStr = ""

0 commit comments

Comments
 (0)