-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdesign.go
More file actions
474 lines (443 loc) · 13.8 KB
/
Copy pathdesign.go
File metadata and controls
474 lines (443 loc) · 13.8 KB
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
package api
import (
. "goa.design/goa/v3/dsl"
_ "goa.design/plugins/v3/zerologger"
)
var _ = API("tibuild", func() {
Title("TiBuild API")
Description("TiBuild API")
Version("2.0.0")
Contact(func() {
Name("Flare Zuo")
Email("wuhui.zuo@pingcap.com")
URL("https://github.com/wuhuizuo")
})
Server("tibuild", func() {
Host("development", func() {
URI("http://localhost:8080")
})
Host("product", func() {
URI("http://0.0.0.0:8080")
})
})
HTTP(func() {
// Add prefix to all API paths
Path("/api/v2")
})
})
var _ = Service("artifact", func() {
Description("The artifact service provides operations to manage artifacts.")
Error("BadRequest", HTTPError, "Bad Request")
Error("InternalServerError", HTTPError, "Internal Server Error")
HTTP(func() {
Path("/artifact")
})
Method("syncImage", func() {
Description("Sync hotfix image to dockerhub")
Payload(ImageSyncRequest)
Result(ImageSyncRequest)
HTTP(func() {
POST("/sync-image")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
})
var _ = Service("devbuild", func() {
Description("The devbuild service provides operations to manage dev builds.")
Error("BadRequest", HTTPError, "Bad Request")
Error("InternalServerError", HTTPError, "Internal Server Error")
HTTP(func() {
Path("/devbuilds")
})
Method("list", func() {
Description("List devbuild with pagination support")
Payload(func() {
Attribute("page", Int, "The page number of items", func() {
Default(1)
})
Attribute("pageSize", Int, "Page size", func() {
Default(30)
})
Attribute("hotfix", Boolean, "Filter hotfix", func() {
Default(false)
})
Attribute("sort", String, "What to sort results by", func() {
Enum("createdAt", "updatedAt")
Default("createdAt")
})
Attribute("direction", String, "The direction of the sort", func() {
Enum("asc", "desc")
Default("desc")
})
Attribute("createdBy", String, "Filter created by")
})
Result(ArrayOf(DevBuild), "List of dev builds")
HTTP(func() {
GET("/")
Param("page")
Param("pageSize")
Param("hotfix")
Param("sort")
Param("direction")
Param("createdBy")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
})
})
Method("create", func() {
Description("Create and trigger devbuild")
Payload(func() {
Attribute("createdBy", String, "Creator of build", func() {
Format(FormatEmail)
})
Attribute("request", DevBuildSpec, "Build to create, only spec field is required, others are ignored", func() {
Required("product", "version", "edition", "gitRef")
})
Attribute("dryrun", Boolean, "Dry run", func() {
Default(false)
})
Required("createdBy", "request")
})
Result(DevBuild)
HTTP(func() {
POST("/")
Param("dryrun")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
Method("get", func() {
Description("Get devbuild")
Payload(func() {
Attribute("id", Int, "ID of build", func() {
Example(1)
})
Attribute("sync", Boolean, "Whether sync with jenkins", func() {
Default(false)
})
Required("id")
})
Result(DevBuild)
Error("http_error", HTTPError, "Bad Request")
HTTP(func() {
GET("/{id}")
Param("sync")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
Method("update", func() {
Description("Update devbuild status")
Payload(func() {
Attribute("id", Int, "ID of build", func() {
Example(1)
})
Attribute("status", DevBuildStatus, "Status to update")
Attribute("dryrun", Boolean, "Dry run", func() {
Default(false)
})
Required("id", "status")
})
Result(DevBuild)
HTTP(func() {
PUT("/{id}")
Param("dryrun")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
Method("rerun", func() {
Description("Rerun devbuild")
Payload(func() {
Attribute("id", Int, "ID of build", func() {
Example(1)
})
Attribute("dryrun", Boolean, "Dry run", func() {
Default(false)
})
Required("id")
})
Result(DevBuild)
HTTP(func() {
POST("/{id}/rerun")
Param("dryrun")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
})
var _ = Service("hotfix", func() {
Description("The hotfix service provides operations to manage hotfix git tags.")
Error("BadRequest", HTTPError, "Bad Request")
Error("InternalServerError", HTTPError, "Internal Server Error")
HTTP(func() {
Path("/hotfix")
})
Method("bump-tag-for-tidbx", func() {
Description("Create a hot fix git tag for a GitHub repository")
Payload(func() {
Attribute("repo", String, "Full name of GitHub repository (e.g., 'owner/repo')", func() {
Example("pingcap/tidb")
})
Attribute("branch", String, "Branch name of the GitHub repo", func() {
Example("release-8.5")
})
Attribute("commit", String, "Short or full git commit SHA", func() {
Example("abc123def456")
})
Attribute("author", String, "The email who requested to create the git tag", func() {
Example("abc@test.com")
})
Attribute("meta", TiDBxBumpTagMeta, "meta data for the bumping context")
Required("repo", "author")
})
Result(HotfixTagResult)
HTTP(func() {
POST("/bump-tag-for-tidbx")
POST("/tidbx/bump-tag")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
Method("query-tag-of-tidbx", func() {
Description("Query tag info of tidbx repo")
Payload(func() {
Attribute("repo", String, "Full name of GitHub repository (e.g., 'owner/repo')", func() {
Example("pingcap/tidb")
})
Attribute("tag", String, "Tag name of the GitHub repo", func() {
Example("v26.3.1-nextgen")
})
Required("repo", "tag")
})
Result(HotfixTagResult)
HTTP(func() {
GET("/tidbx/tag")
Param("repo")
Param("tag")
Response(StatusOK)
Response("BadRequest", StatusBadRequest)
Response("InternalServerError", StatusInternalServerError)
})
})
})
var ImageSyncRequest = Type("ImageSyncRequest", func() {
Attribute("source", String)
Attribute("target", String)
Required("source", "target")
})
var DevBuild = Type("DevBuild", func() {
Attribute("id", Int)
Attribute("meta", DevBuildMeta)
Attribute("spec", DevBuildSpec)
Attribute("status", DevBuildStatus)
Required("id", "meta", "spec", "status")
})
var DevBuildMeta = Type("DevBuildMeta", func() {
Attribute("createdBy", String, func() {
Format(FormatEmail)
})
Attribute("createdAt", String, func() {
Format(FormatDateTime)
})
Attribute("updatedAt", String, func() {
Format(FormatDateTime)
})
Required("createdAt", "createdBy", "updatedAt")
})
var DevBuildSpec = Type("DevBuildSpec", func() {
Attribute("buildEnv", String)
Attribute("builderImg", String)
Attribute("edition", String, func() {
Enum("enterprise", "community", "fips", "failpoint", "experiment", "nextgen", "next-gen")
})
Attribute("platform", String, func() {
Default("linux")
Enum("all", "linux", "darwin", "linux/amd64", "linux/arm64", "darwin/amd64", "darwin/arm64")
})
Attribute("features", String, func() {
Description("[Deprecated] use buildEnv for custom features")
})
Attribute("gitRef", String)
Attribute("gitHash", String)
Attribute("githubRepo", String)
Attribute("isHotfix", Boolean)
Attribute("isPushGCR", Boolean)
Attribute("pipelineEngine", String, func() {
Enum("jenkins", "tekton")
})
Attribute("pluginGitRef", String)
Attribute("product", String, func() {
Enum(
"dm", // from pingcap/tiflow repo.
"enterprise-plugin", // from pingcap-inc/enterprise-plugin repo.
"ng-monitoring", // from pingcap/ng-monitoring repo.
"pd", // from tikv/pd repo.
"ticdc", // from pingcap/tiflow or pingcap/ticdc repo.
"ticdc-newarch", // from pingcap/ticdc repo.
"tici", // from pingcap-inc/tici repo.
"tidb", "br", "dumpling", "tidb-lightning", // from pingcap/tidb repo.
"tidb-binlog", "drainer", "pump", // from pingcap/tidb-binlog repo.
"tidb-dashboard", // from pingcap/tidb-dashboard repo.
"tidb-operator", // from pingcap/tidb-operator repo.
"tidb-tools", // from pingcap/tidb-tools repo.
"tiflash", // from pingcap/tiflash repo.
"tikv", // from tikv/tikv repo.
"tiproxy", // from pingcap/tiproxy repo.
)
})
Attribute("productBaseImg", String)
Attribute("productDockerfile", String)
Attribute("targetImg", String)
Attribute("version", String)
})
var DevBuildStatus = Type("DevBuildStatus", func() {
Attribute("buildReport", BuildReport)
Attribute("errMsg", String)
Attribute("pipelineBuildID", Int)
Attribute("pipelineStartAt", String, func() {
Format(FormatDateTime)
})
Attribute("pipelineEndAt", String, func() {
Format(FormatDateTime)
})
Attribute("pipelineViewURL", String, func() { Format(FormatURI) })
Attribute("pipelineViewURLs", ArrayOf(String, func() { Format(FormatURI) }))
Attribute("status", BuildStatus)
Attribute("tektonStatus", TektonStatus)
Required("status")
})
var BuildReport = Type("BuildReport", func() {
Attribute("binaries", ArrayOf(BinArtifact))
Attribute("gitHash", String, func() { MaxLength(40) })
Attribute("images", ArrayOf(ImageArtifact))
Attribute("pluginGitHash", String, func() { MaxLength(40) })
Attribute("printedVersion", String)
})
var BinArtifact = Type("BinArtifact", func() {
Attribute("component", String)
Attribute("ociFile", OciFile)
Attribute("platform", String)
Attribute("sha256OCIFile", OciFile)
Attribute("sha256URL", String, func() { Format(FormatURI) })
Attribute("url", String, func() { Format(FormatURI) })
})
var OciFile = Type("OciFile", func() {
Attribute("file", String)
Attribute("repo", String)
Attribute("tag", String)
Required("file", "repo", "tag")
})
var ImageArtifact = Type("ImageArtifact", func() {
Attribute("platform", String)
Attribute("url", String)
Attribute("internalURL", String)
Required("platform", "url")
})
var TektonStatus = Type("TektonStatus", func() {
Attribute("pipelines", ArrayOf(TektonPipeline))
Attribute("triggersEventIDs", ArrayOf(String, func() { Format(FormatUUID) }))
Required("pipelines")
})
var TektonPipeline = Type("TektonPipeline", func() {
Attribute("name", String)
Attribute("namespace", String)
Attribute("status", TektonPipelineRunStatus)
Attribute("startAt", String, func() { Format(FormatDateTime) })
Attribute("endAt", String, func() { Format(FormatDateTime) })
Attribute("images", ArrayOf(ImageArtifact))
Attribute("ociArtifacts", ArrayOf(OciArtifact))
Attribute("platform", String)
Attribute("url", String, func() { Format(FormatURI) })
Required("name", "namespace", "status")
})
var OciArtifact = Type("OciArtifact", func() {
Attribute("files", ArrayOf(String))
Attribute("repo", String)
Attribute("tag", String)
Required("files", "repo", "tag")
})
var BuildStatus = Type("BuildStatus", String, func() {
Enum("PENDING", "PROCESSING", "ABORTED", "SUCCESS", "FAILURE", "ERROR")
})
var TektonPipelineRunStatus = Type("TektonPipelineRunStatus", String, func() {
Enum("Started", "Running", "Succeeded", "Failed", "Cancelled", "Skipped", "TimedOut", "ExceededNodeResources")
})
var HTTPError = Type("HTTPError", func() {
Attribute("code", Int)
Attribute("message", String)
Required("code", "message")
})
var CloudEvent = Type("CloudEvent", func() {
Attribute("id", String, "Unique identifier for the event", func() {
Example("f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
})
Attribute("source", String, "Identifies the context in which an event happened", func() {
Example("/jenkins/build")
})
Attribute("type", String, "Describes the type of event related to the originating occurrence", func() {
Example("com.pingcap.build.complete")
})
Attribute("datacontenttype", String, "Content type of the data value")
Attribute("specversion", String, "The version of the CloudEvents specification which the event uses", func() {
Example("1.0")
})
Attribute("dataschema", String, "Identifies the schema that data adheres to", func() {
Example("https://example.com/registry/schemas/build-event.json")
})
Attribute("subject", String, "Describes the subject of the event in the context of the event producer", func() {
Example("tidb-build-123")
})
Attribute("time", String, "Timestamp of when the occurrence happened", func() {
Format(FormatDateTime)
Example("2022-10-01T12:00:00Z")
})
Attribute("data", Any, "Event payload", func() {
Example(map[string]any{
"buildId": "123",
"status": "success",
"version": "v6.1.0",
"duration": 3600,
})
})
})
var HotfixTagResult = Type("HotfixTagResult", func() {
Attribute("repo", String, "Full name of GitHub repository", func() {
Example("pingcap/tidb")
})
Attribute("commit", String, "The commit tag created on", func() {
Example("abc123def456789")
})
Attribute("tag", String, "Git tag name", func() {
Example("v8.5.4-nextgen.202510.10")
})
Attribute("author", String, "The email who requested to create the git tag", func() {
Example("abc@test.com")
})
Attribute("meta", TiDBxBumpTagMeta, "meta data")
Required("repo", "commit", "tag")
})
var TiDBxBumpTagMeta = Type("TiDBxBumpTagMeta", func() {
Attribute("ops_req", func() {
Attribute("applicant", String, func() {
Example("tidb")
Meta("struct:tag:json", "applicant,omitempty")
})
Attribute("release_id", String, func() {
Example("r1")
Meta("struct:tag:json", "release_id,omitempty")
})
Attribute("change_id", String, func() {
Example("c1")
Meta("struct:tag:json", "change_id,omitempty")
})
Meta("struct:tag:json", "ops_req,omitempty")
})
})