forked from evergreen-ci/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.go
165 lines (133 loc) · 4.03 KB
/
globals.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
package evergreen
import (
"fmt"
"os"
"github.com/mongodb/grip"
"github.com/mongodb/grip/send"
"github.com/mongodb/grip/slogger"
)
const (
User = "mci"
HostRunning = "running"
HostTerminated = "terminated"
HostUninitialized = "starting"
HostInitializing = "provisioning"
HostProvisionFailed = "provision failed"
HostUnreachable = "unreachable"
HostQuarantined = "quarantined"
HostDecommissioned = "decommissioned"
HostStatusSuccess = "success"
HostStatusFailed = "failed"
TaskStarted = "started"
TaskUndispatched = "undispatched"
TaskDispatched = "dispatched"
TaskFailed = "failed"
TaskSucceeded = "success"
TaskInactive = "inactive"
TaskSystemFailed = "system-failed"
TaskTimedOut = "task-timed-out"
TaskSystemUnresponse = "system-unresponse"
TaskSystemTimedOut = "system-timed-out"
TaskTestTimedOut = "test-timed-out"
TestFailedStatus = "fail"
TestSilentlyFailedStatus = "silentfail"
TestSkippedStatus = "skip"
TestSucceededStatus = "pass"
BuildStarted = "started"
BuildCreated = "created"
BuildFailed = "failed"
BuildSucceeded = "success"
VersionStarted = "started"
VersionCreated = "created"
VersionFailed = "failed"
VersionSucceeded = "success"
PatchCreated = "created"
PatchStarted = "started"
PatchSucceeded = "succeeded"
PatchFailed = "failed"
PushLogPushing = "pushing"
PushLogSuccess = "success"
HostTypeStatic = "static"
CompileStage = "compile"
PushStage = "push"
// maximum task (zero based) execution number
MaxTaskExecution = 3
// maximum task priority
MaxTaskPriority = 100
// LogMessage struct versions
LogmessageFormatTimestamp = 1
LogmessageCurrentVersion = LogmessageFormatTimestamp
EvergreenHome = "EVGHOME"
DefaultTaskActivator = ""
StepbackTaskActivator = "stepback"
APIServerTaskActivator = "apiserver"
RestRoutePrefix = "rest"
AgentAPIVersion = 2
)
// evergreen package names
const (
UIPackage = "EVERGREEN_UI"
RESTV2Package = "EVERGREEN_REST_V2"
)
const (
AuthTokenCookie = "mci-token"
TaskSecretHeader = "Task-Secret"
HostHeader = "Host-Id"
HostSecretHeader = "Host-Secret"
)
// HTTP constants. Added after Go1.4. Here for compatibility with GCCGO
// compatibility. Copied from: https://golang.org/pkg/net/http/#pkg-constants
const (
MethodGet = "GET"
MethodHead = "HEAD"
MethodPost = "POST"
MethodPut = "PUT"
MethodPatch = "PATCH" // RFC 5789
MethodDelete = "DELETE"
MethodConnect = "CONNECT"
MethodOptions = "OPTIONS"
MethodTrace = "TRACE"
)
var (
// UphostStatus is a list of all host statuses that are considered "up."
// This is used for query building.
UphostStatus = []string{
HostRunning,
HostUninitialized,
HostInitializing,
HostProvisionFailed,
}
// Logger is our global logger. It can be changed for testing.
Logger slogger.Logger
// database and config directory, set to the testing version by default for safety
NotificationsFile = "mci-notifications.yml"
ClientDirectory = "clients"
// version requester types
PatchVersionRequester = "patch_request"
RepotrackerVersionRequester = "gitter_request"
// constant arrays for db update logic
AbortableStatuses = []string{TaskStarted, TaskDispatched}
CompletedStatuses = []string{TaskSucceeded, TaskFailed}
)
// SetLegacyLogger sets the global (s)logger instance to wrap the current grip Logger.
func SetLegacyLogger() {
Logger = slogger.Logger{
Name: fmt.Sprintf("evg-gloal.%s", grip.Name()),
Appenders: []send.Sender{grip.GetSender()},
}
}
// FindEvergreenHome finds the directory of the EVGHOME environment variable.
func FindEvergreenHome() string {
// check if env var is set
root := os.Getenv(EvergreenHome)
if len(root) > 0 {
return root
}
Logger.Logf(slogger.ERROR, "%s is unset", EvergreenHome)
return ""
}
// IsSystemActivator returns true when the task activator is Evergreen.
func IsSystemActivator(caller string) bool {
return caller == DefaultTaskActivator ||
caller == APIServerTaskActivator
}