-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
94 lines (78 loc) · 1.39 KB
/
structs.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package common
import "github.com/hohn/ghes-mirva-server/api"
type AnalyzeResult struct {
RunAnalysisSARIF string
RunAnalysisBQRS string
}
type OwnerRepo struct {
Owner string
Repo string
}
type B64GzTar struct {
TGZFilepath string
}
type DBLocation struct {
DBPATH string
}
type DBLocationLocal struct {
prefix string
db_file string
}
type JobInfo struct {
QueryLanguage string
CreatedAt string
UpdatedAt string
SkippedRepositories api.SkippedRepositories
}
type JobSpec struct {
ID int
OwnerRepo
}
type Status int
const (
StatusInProgress = iota
StatusQueued
StatusError
StatusSuccess
StatusFailed
)
type AnalyzeJob struct {
MirvaRequestID int
QueryPackId int
QueryLanguage string
ORL OwnerRepo
}
func StatusFromString(status string) Status {
switch status {
case "in_progress":
return StatusInProgress
case "InProgress":
return StatusInProgress
case "Queued":
return StatusQueued
case "Error":
return StatusError
case "Success":
return StatusSuccess
case "Failed":
return StatusFailed
default:
return -1 // or handle the invalid status case accordingly
}
}
func (s Status) ToExternalString() string {
switch s {
case StatusInProgress:
return "in_progress"
case StatusQueued:
return "queued"
case StatusError:
return "error"
case StatusSuccess:
return "succeeded"
case StatusFailed:
return "failed"
default:
return "unknown"
}
}