-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpctype.go
62 lines (54 loc) · 988 Bytes
/
rpctype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Package testbot contains type declarations used across
// multiple testbot-related packages.
package testbot
import (
"errors"
"path"
"strings"
"time"
)
type BoxPingReq struct {
ID string
Host string
}
type Job struct {
SHA string
Dir string
Name string
}
func ParseJob(s string) (j Job, err error) {
i := strings.IndexByte(s, '/')
if i < 0 {
return Job{}, errors.New("bad job")
}
j.SHA = s[:i]
if strings.TrimLeft(j.SHA, "0123456789abcdefABCDEF") != "" {
return Job{}, errors.New("bad job: non-hex char in commit hash")
}
j.Dir, j.Name = path.Split(s[i:])
j.Dir = strings.TrimRight(j.Dir, "/")
if j.Dir == "" {
j.Dir = "/"
}
if j.Name == "" {
return Job{}, errors.New("bad job: no name")
}
return j, nil
}
type BoxState struct {
ID string
Job Job
}
type BoxJobUpdateReq struct {
Job Job
Status string
Desc string
URL string
Elapsed time.Duration
}
type RetryReq struct {
ResultID int
}
type CancelReq struct {
Job Job
}