-
Notifications
You must be signed in to change notification settings - Fork 807
/
consts.go
491 lines (404 loc) · 13.5 KB
/
consts.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
/*
Copyright 2021 The KodeRover Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"regexp"
"time"
"github.com/koderover/zadig/pkg/setting"
)
var (
// RenderTemplateAlias ...
RenderTemplateAlias = regexp.MustCompile(`{{\s?\.\w+\s?}}`)
ServiceNameAlias = regexp.MustCompile(`\$Service\$`)
ProductNameAlias = regexp.MustCompile(`\$Product\$`)
NameSpaceRegex = regexp.MustCompile(NameSpaceRegexString)
)
const (
ServiceNameRegexString = "^[a-zA-Z0-9-_]+$"
ConfigNameRegexString = "^[a-zA-Z0-9-]+$"
ImageRegexString = "^[a-zA-Z0-9.:\\/-]+$"
CVMNameRegexString = "^[a-zA-Z_]\\w+$"
EnvRecyclePolicyAlways = "always"
EnvRecyclePolicyTaskStatus = "success"
EnvRecyclePolicyNever = "never"
// 定时器的所属job类型
WorkflowCronjob = "workflow"
WorkflowV4Cronjob = "workflow_v4"
TestingCronjob = "test"
EnvAnalysisCronjob = "env_analysis"
)
var (
ServiceNameRegex = regexp.MustCompile(ServiceNameRegexString)
ConfigNameRegex = regexp.MustCompile(ConfigNameRegexString)
ImageRegex = regexp.MustCompile(ImageRegexString)
CVMNameRegex = regexp.MustCompile(CVMNameRegexString)
)
// ScheduleType 触发模式
type ScheduleType string
const (
// TimingSchedule 定时循环
TimingSchedule ScheduleType = "timing"
// GapSchedule 间隔循环
GapSchedule ScheduleType = "gap"
)
type SlackNotifyType string
const (
// SlackAll SlackNotifyType = "all"
SlackOnChange SlackNotifyType = "onchange"
SlackOnfailure SlackNotifyType = "onfailure"
)
// Type pipeline type
type PipelineType string
const (
// SingleType 单服务工作流
SingleType PipelineType = "single"
// WorkflowType 多服务工作流
WorkflowType PipelineType = "workflow"
// FreestyleType 自由编排工作流
FreestyleType PipelineType = "freestyle"
// TestType 测试
TestType PipelineType = "test"
// ServiceType 服务
ServiceType PipelineType = "service"
// WorkflowTypeV3
WorkflowTypeV3 PipelineType = "workflow_v3"
// WorkflowTypeV4
WorkflowTypeV4 PipelineType = "workflow_v4"
// ArtifactPackageType package artifact
ArtifactType PipelineType = "artifact"
// ScanningType is the type for scanning
ScanningType PipelineType = "scanning"
)
type Status string
const (
StatusDisabled Status = "disabled"
StatusCreated Status = "created"
StatusRunning Status = "running"
StatusPassed Status = "passed"
StatusSkipped Status = "skipped"
StatusFailed Status = "failed"
StatusTimeout Status = "timeout"
StatusCancelled Status = "cancelled"
StatusWaiting Status = "waiting"
StatusQueued Status = "queued"
StatusBlocked Status = "blocked"
QueueItemPending Status = "pending"
StatusChanged Status = "changed"
StatusNotRun Status = "notRun"
StatusPrepare Status = "prepare"
StatusReject Status = "reject"
StatusWaitingApprove Status = "waitforapprove"
StatusDebugBefore Status = "debug_before"
StatusDebugAfter Status = "debug_after"
)
func InCompletedStatus() []Status {
return []Status{StatusCreated, StatusRunning, StatusWaiting, StatusQueued, StatusBlocked, QueueItemPending, StatusPrepare, StatusWaitingApprove}
}
type TaskStatus string
const (
TaskStatusRunning TaskStatus = "running"
TaskStatusCompleted TaskStatus = "completed"
TaskStatusReady TaskStatus = "ready"
TaskStatusFailed TaskStatus = "failed"
TaskStatusTimeout TaskStatus = "timeout"
TaskStatusCancelled TaskStatus = "cancelled"
TaskStatusPass TaskStatus = "pass"
)
type TaskType string
const (
TaskPipeline TaskType = "pipeline"
TaskBuild TaskType = "buildv2"
TaskBuildV3 TaskType = "buildv3"
TaskJenkinsBuild TaskType = "jenkins_build"
TaskArtifact TaskType = "artifact"
TaskArtifactDeploy TaskType = "artifact_deploy"
TaskDeploy TaskType = "deploy"
TaskTestingV2 TaskType = "testingv2"
TaskScanning TaskType = "scanning"
TaskDistributeToS3 TaskType = "distribute2kodo"
TaskReleaseImage TaskType = "release_image"
TaskJira TaskType = "jira"
TaskDockerBuild TaskType = "docker_build"
TaskSecurity TaskType = "security"
TaskResetImage TaskType = "reset_image"
TaskDistribute TaskType = "distribute"
TaskTrigger TaskType = "trigger"
TaskExtension TaskType = "extension"
TaskArtifactPackage TaskType = "artifact_package"
)
type StepType string
const (
StepTools StepType = "tools"
StepShell StepType = "shell"
StepGit StepType = "git"
StepDockerBuild StepType = "docker_build"
StepDeploy StepType = "deploy"
StepHelmDeploy StepType = "helm_deploy"
StepCustomDeploy StepType = "custom_deploy"
StepImageDistribute StepType = "image_distribute"
StepArchive StepType = "archive"
StepArchiveDistribute StepType = "archive_distribute"
StepJunitReport StepType = "junit_report"
StepHtmlReport StepType = "html_report"
StepTarArchive StepType = "tar_archive"
StepSonarCheck StepType = "sonar_check"
StepDistributeImage StepType = "distribute_image"
StepDebugBefore StepType = "debug_before"
StepDebugAfter StepType = "debug_after"
)
type JobType string
const (
JobBuild JobType = "build"
JobDeploy JobType = "deploy"
JobZadigBuild JobType = "zadig-build"
JobZadigDistributeImage JobType = "zadig-distribute-image"
JobZadigTesting JobType = "zadig-test"
JobZadigScanning JobType = "zadig-scanning"
JobCustomDeploy JobType = "custom-deploy"
JobZadigDeploy JobType = "zadig-deploy"
JobZadigHelmDeploy JobType = "zadig-helm-deploy"
JobZadigHelmChartDeploy JobType = "zadig-helm-chart-deploy"
JobFreestyle JobType = "freestyle"
JobPlugin JobType = "plugin"
JobK8sBlueGreenDeploy JobType = "k8s-blue-green-deploy"
JobK8sBlueGreenRelease JobType = "k8s-blue-green-release"
JobK8sCanaryDeploy JobType = "k8s-canary-deploy"
JobK8sCanaryRelease JobType = "k8s-canary-release"
JobK8sGrayRelease JobType = "k8s-gray-release"
JobK8sGrayRollback JobType = "k8s-gray-rollback"
JobK8sPatch JobType = "k8s-resource-patch"
JobIstioRelease JobType = "istio-release"
JobIstioRollback JobType = "istio-rollback"
JobJira JobType = "jira"
JobNacos JobType = "nacos"
JobApollo JobType = "apollo"
JobMeegoTransition JobType = "meego-transition"
JobWorkflowTrigger JobType = "workflow-trigger"
JobOfflineService JobType = "offline-service"
JobMseGrayRelease JobType = "mse-gray-release"
JobMseGrayOffline JobType = "mse-gray-offline"
)
const (
ZadigIstioCopySuffix = "zadig-copy"
ZadigLastAppliedImage = "last-applied-image"
ZadigLastAppliedReplicas = "last-applied-replicas"
)
type ApprovalType string
const (
NativeApproval ApprovalType = "native"
LarkApproval ApprovalType = "lark"
DingTalkApproval ApprovalType = "dingtalk"
)
type ApproveOrReject string
const (
Approve ApproveOrReject = "approve"
Reject ApproveOrReject = "reject"
)
type DeploySourceType string
const (
SourceRuntime DeploySourceType = "runtime"
SourceFromJob DeploySourceType = "fromjob"
)
type TriggerWorkflowSourceType string
const (
TriggerWorkflowSourceRuntime TriggerWorkflowSourceType = "runtime"
TriggerWorkflowSourceFromJob TriggerWorkflowSourceType = "fromjob"
)
type EnvType string
const (
EnvTypeTest = "test"
EvnTypeProduction = "production"
)
type TestModuleType string
const (
ProductTestType TestModuleType = ""
ServiceTestType TestModuleType = "service_test"
)
type DeployContent string
const (
DeployImage DeployContent = "image"
DeployVars DeployContent = "vars"
DeployConfig DeployContent = "config"
)
type StageType string
const (
StageCustom StageType = "custom"
StepApproval StageType = "approval"
)
type DistributeType string
const (
File DistributeType = "file"
Image DistributeType = "image"
Chart DistributeType = "chart"
)
type NotifyType int
var (
Announcement NotifyType = 1 // 公告
PipelineStatus NotifyType = 2 // 提醒
Message NotifyType = 3 // 消息
)
// Validation constants
const (
NameSpaceRegexString = "[^a-z0-9.-]"
)
// ProductPermission ...
type ProductPermission string
// ProductAuthType ...
type ProductAuthType string
const (
// ProductReadPermission ...
ProductReadPermission = ProductPermission("read")
// ProductWritePermission ...
ProductWritePermission = ProductPermission("write")
)
const (
// ProductAuthUser ...
ProductAuthUser = ProductAuthType("user")
// ProductAuthTeam ...
ProductAuthTeam = ProductAuthType("team")
)
type HookEventType string
const (
HookEventPush = HookEventType("push")
HookEventPr = HookEventType("pull_request")
HookEventTag = HookEventType("tag")
HookEventUpdated = HookEventType("ref-updated")
)
const (
KeyStateNew = "new"
KeyStateUnused = "unused"
KeyStatePresent = "present"
)
const (
Day = 7
LatestDay = 10
Date = "2006-01-02"
)
const (
RegistryTypeSWR = "swr"
RegistryTypeAWS = "ecr"
)
const (
ImageResourceType = "image"
TarResourceType = "tar"
)
const (
RoleBindingNameEdit = setting.ProductName + "-edit"
RoleBindingNameView = setting.ProductName + "-view"
)
type CommonEnvCfgType string
const (
CommonEnvCfgTypeIngress CommonEnvCfgType = "Ingress"
CommonEnvCfgTypeConfigMap CommonEnvCfgType = "ConfigMap"
CommonEnvCfgTypeSecret CommonEnvCfgType = "Secret"
CommonEnvCfgTypePvc CommonEnvCfgType = "PVC"
)
// for custom blue-green release job
const (
BlueGreenVerionLabelName = "zadig-blue-green-version"
BlueServiceNameSuffix = "-zadig-blue"
OriginVersion = "origin"
)
// for custom gray release job
const (
GrayLabelKey = "zadig-gray-release"
GrayLabelValue = "released-by-zadig"
GrayImageAnnotationKey = "zadig-gray-release-image"
GrayContainerAnnotationKey = "zadig-gray-release-container"
GrayReplicaAnnotationKey = "zadig-gray-release-replica"
GrayDeploymentSuffix = "-zadig-gray"
)
type WorkflowTriggerType string
const (
WorkflowTriggerTypeCommon WorkflowTriggerType = "common"
WorkflowTriggerTypeFixed WorkflowTriggerType = "fixed"
)
type ProjectType string
const (
ProjectTypeHelm = "helm"
ProjectTypeYaml = "yaml"
ProjectTypeVM = "vm"
ProjectTypeLoaded = "loaded"
)
type ParamSourceType string
const (
ParamSourceRuntime = "runtime"
ParamSourceFixed = "fixed"
ParamSourceGlobal = "global"
)
type RegistryProvider string
const (
RegistryProviderACR = "acr"
RegistryProviderSWR = "swr"
RegistryProviderTCR = "tcr"
RegistryProviderHarbor = "harbor"
RegistryProviderDockerhub = "dockerhub"
RegistryProviderECR = "ecr"
RegistryProviderNative = "native"
)
const (
TestJobJunitReportStepName = "junit-report-step"
TestJobHTMLReportStepName = "html-report-step"
TestJobArchiveResultStepName = "archive-result-step"
TestJobObjectStorageStepName = "object-storage-step"
)
type JobRunPolicy string
const (
DefaultRun JobRunPolicy = "" // default run this job
DefaultNotRun JobRunPolicy = "default_not_run" // default not run this job
ForceRun JobRunPolicy = "force_run" // force run this job
)
const DefaultDeleteDeploymentTimeout = 10 * time.Minute
// Service creation source for openAPI
const (
SourceFromTemplate = "template"
SourceFromYaml = "yaml"
)
type JiraAuthType string
const (
JiraBasicAuth JiraAuthType = "password_or_token"
JiraPersonalAccessToken JiraAuthType = "personal_access_token"
)
// statistics dashboard id enum
const (
DashboardDataTypeTestPassRate = "test_pass_rate"
DashboardDataTypeTestAverageDuration = "test_average_duration"
DashboardDataTypeBuildSuccessRate = "build_success_rate"
DashboardDataTypeBuildAverageDuration = "build_average_duration"
DashboardDataTypeBuildFrequency = "build_frequency"
DashboardDataTypeDeploySuccessRate = "deploy_success_rate"
DashboardDataTypeDeployAverageDuration = "deploy_average_duration"
DashboardDataTypeDeployFrequency = "deploy_frequency"
DashboardDataTypeReleaseSuccessRate = "release_success_rate"
DashboardDataTypeReleaseAverageDuration = "release_average_duration"
DashboardDataTypeReleaseFrequency = "release_frequency"
DashboardDataSourceZadig = "zadig"
DashboardDataSourceApi = "api"
DashboardDataCategoryQuality = "quality"
DashboardDataCategoryEfficiency = "efficiency"
DashboardDataCategorySchedule = "schedule"
DashboardFunctionBuildAverageDuration = "5400/(x+540)"
DashboardFunctionBuildSuccessRate = "-2400/(x-120)-20"
DashboardFunctionDeploySuccessRate = "-2400/(x-120)-20"
DashboardFunctionDeployFrequency = "100-40000/(3*x+400)"
DashboardFunctionTestPassRate = "(x**2)/80-x/4+1.25"
DashboardFunctionTestAverageDuration = "90000/(x+900)"
DashboardFunctionReleaseFrequency = "100-200/(x+2)"
)
const (
CUSTOME_THEME = "custom"
)
type ZadigXReleaseType string
var (
ZadigXMseGrayRelease ZadigXReleaseType = "mse-gray"
)