feat: support batchJob for windows (#19877)

This commit is contained in:
jiuker 2024-06-05 23:44:53 +08:00 committed by GitHub
parent 91e1487de4
commit d326ba52e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 3 deletions

View File

@ -21,7 +21,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.22.3 go-version: 1.22.4
check-latest: true check-latest: true
- name: Get official govulncheck - name: Get official govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest run: go install golang.org/x/vuln/cmd/govulncheck@latest

View File

@ -1633,7 +1633,7 @@ func (a adminAPIHandlers) StartBatchJob(w http.ResponseWriter, r *http.Request)
return return
} }
job.ID = fmt.Sprintf("%s:%d", shortuuid.New(), GetProxyEndpointLocalIndex(globalProxyEndpoints)) job.ID = fmt.Sprintf("%s%s%d", shortuuid.New(), getBatchJobIDSeparator(), GetProxyEndpointLocalIndex(globalProxyEndpoints))
job.User = user job.User = user
job.Started = time.Now() job.Started = time.Now()

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"fmt" "fmt"
"runtime"
"strings" "strings"
"time" "time"
@ -288,3 +289,12 @@ func (s *BatchJobSize) UnmarshalYAML(unmarshal func(interface{}) error) error {
*s = BatchJobSize(sz) *s = BatchJobSize(sz)
return nil return nil
} }
// getBatchJobIDSeparator - returns the separator to be used in the batch job ID
// windows requires `_` as the separator `:` will be an invalid one
func getBatchJobIDSeparator() string {
if runtime.GOOS == globalWindowsOSName {
return "_"
}
return ":"
}

View File

@ -231,7 +231,7 @@ func parseRequestToken(token string) (subToken string, nodeIndex int) {
if token == "" { if token == "" {
return token, -1 return token, -1
} }
i := strings.Index(token, ":") i := strings.Index(token, getBatchJobIDSeparator())
if i < 0 { if i < 0 {
return token, -1 return token, -1
} }