forked from gaia-pipeline/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaia.go
166 lines (134 loc) · 4.67 KB
/
gaia.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package gaia
import (
"os"
"time"
hclog "github.com/hashicorp/go-hclog"
)
// PipelineType represents supported plugin types
type PipelineType string
// CreatePipelineType represents the different status types
// a create pipeline can have.
type CreatePipelineType string
// PipelineRunStatus represents the different status a run
// can have.
type PipelineRunStatus string
// JobStatus represents the different status a job can have.
type JobStatus string
const (
// PTypeUnknown unknown plugin type
PTypeUnknown PipelineType = "unknown"
// PTypeGolang golang plugin type
PTypeGolang PipelineType = "golang"
// CreatePipelineFailed status
CreatePipelineFailed CreatePipelineType = "failed"
// CreatePipelineRunning status
CreatePipelineRunning CreatePipelineType = "running"
// CreatePipelineSuccess status
CreatePipelineSuccess CreatePipelineType = "success"
// RunNotScheduled status
RunNotScheduled PipelineRunStatus = "not scheduled"
// RunScheduled status
RunScheduled PipelineRunStatus = "scheduled"
// RunFailed status
RunFailed PipelineRunStatus = "failed"
// RunSuccess status
RunSuccess PipelineRunStatus = "success"
// RunRunning status
RunRunning PipelineRunStatus = "running"
// JobWaitingExec status
JobWaitingExec JobStatus = "waiting for execution"
// JobSuccess status
JobSuccess JobStatus = "success"
// JobFailed status
JobFailed JobStatus = "failed"
// JobRunning status
JobRunning JobStatus = "running"
// LogsFolderName represents the Name of the logs folder in pipeline run folder
LogsFolderName = "logs"
)
// User is the user object
type User struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Tokenstring string `json:"tokenstring,omitempty"`
JwtExpiry int64 `json:"jwtexpiry,omitempty"`
LastLogin time.Time `json:"lastlogin,omitempty"`
}
// Pipeline represents a single pipeline
type Pipeline struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Repo GitRepo `json:"repo,omitempty"`
Type PipelineType `json:"type,omitempty"`
ExecPath string `json:"execpath,omitempty"`
SHA256Sum []byte `json:"sha256sum,omitempty"`
Jobs []Job `json:"jobs,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// GitRepo represents a single git repository
type GitRepo struct {
URL string `json:"url,omitempty"`
Username string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
PrivateKey PrivateKey `json:"privatekey,omitempty"`
SelectedBranch string `json:"selectedbranch,omitempty"`
Branches []string `json:"branches,omitempty"`
LocalDest string
}
// Job represents a single job of a pipeline
type Job struct {
ID uint32 `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"desc,omitempty"`
Priority int64 `json:"priority"`
Status JobStatus `json:"status,omitempty"`
}
// CreatePipeline represents a pipeline which is not yet
// compiled.
type CreatePipeline struct {
ID string `json:"id,omitempty"`
Pipeline Pipeline `json:"pipeline,omitempty"`
Status int `json:"status,omitempty"`
StatusType CreatePipelineType `json:"statustype,omitempty"`
Output string `json:"output,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// PrivateKey represents a pem encoded private key
type PrivateKey struct {
Key string `json:"key,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
// PipelineRun represents a single run of a pipeline.
type PipelineRun struct {
UniqueID string `json:"uniqueid"`
ID int `json:"id"`
PipelineID int `json:"pipelineid"`
StartDate time.Time `json:"startdate,omitempty"`
FinishDate time.Time `json:"finishdate,omitempty"`
ScheduleDate time.Time `json:"scheduledate,omitempty"`
Status PipelineRunStatus `json:"status,omitempty"`
Jobs []Job `json:"jobs,omitempty"`
}
// Cfg represents the global config instance
var Cfg *Config
// Config holds all config options
type Config struct {
DevMode bool
VersionSwitch bool
ListenPort string
HomePath string
DataPath string
PipelinePath string
WorkspacePath string
Worker string
Logger hclog.Logger
Bolt struct {
Mode os.FileMode
}
}
// String returns a pipeline type string back
func (p PipelineType) String() string {
return string(p)
}