Skip to content

Commit 9da93d7

Browse files
feat(tidbcloud): add endpoint to tag tidbx images in TCMS (#388)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1b2141e commit 9da93d7

File tree

27 files changed

+1061
-129
lines changed

27 files changed

+1061
-129
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
# go work files
2121
go.work
2222
go.work.sum
23+
24+
.config

publisher/cmd/publisher/main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func main() {
5757
logLevel = zerolog.DebugLevel
5858
}
5959
zerolog.SetGlobalLevel(logLevel)
60-
logger := zerolog.New(os.Stderr).With().Timestamp().Str("service", tiup.ServiceName).Logger()
60+
loggerCtx := zerolog.New(os.Stderr).With().Timestamp()
6161

6262
// Load and parse configuration
6363
cfg, err := config.Load[config.Service](*configFile)
@@ -66,10 +66,14 @@ func main() {
6666
}
6767

6868
// Initialize the services.
69-
tiupSvc := impltiup.NewService(&logger, *cfg)
70-
fsSvc := implfs.NewService(&logger, *cfg)
71-
imgSvc := implimg.NewService(&logger, *cfg)
72-
tidbcloudSvc := impltidbcloud.NewService(&logger, *cfg)
69+
tiupLogger := loggerCtx.Str("service", "tiup").Logger()
70+
tiupSvc := impltiup.NewService(&tiupLogger, *cfg)
71+
fsLogger := loggerCtx.Str("service", "fileserver").Logger()
72+
fsSvc := implfs.NewService(&fsLogger, *cfg)
73+
imgLogger := loggerCtx.Str("service", "image").Logger()
74+
imgSvc := implimg.NewService(&imgLogger, *cfg)
75+
tidbcloudLogger := loggerCtx.Str("service", "tidbcloud").Logger()
76+
tidbcloudSvc := impltidbcloud.NewService(&tidbcloudLogger, *cfg)
7377

7478
// Wrap the services in endpoints that can be invoked from other services
7579
// potentially running in different processes.

publisher/configs/service-example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ services:
1919

2020
tidbcloud:
2121
# ops_config_file: "tidbcloud-ops-config.yaml" # should load from config map
22+
# testplatforms_config_file: "testplatforms-config.yaml"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tcms:
2+
api_base_url: "https://tcms.example.com/api"
3+
auth_token: "tcms_token"
4+
5+
# Optional credentials for private image access.
6+
image_auth:
7+
username: "registry_user"
8+
password: "registry_password"
9+
use_default_keychain: false

publisher/internal/service/design/design.go

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ var _ = Service("tidbcloud", func() {
353353
Example("prod")
354354
})
355355
Attribute("image", String, "container image with tag", func() {
356-
Example("xxx.com/component:v8.5.4")
356+
Example("xxx.com/component:v8.5.4")
357357
})
358358

359359
Required("stage", "image")
@@ -368,4 +368,50 @@ var _ = Service("tidbcloud", func() {
368368
Response(StatusOK)
369369
})
370370
})
371+
Method("add-tidbx-image-tag-in-tcms", func() {
372+
Payload(func() {
373+
Attribute("image", String, "container image with tag", func() {
374+
Example("xxx.com/component:v8.5.4")
375+
})
376+
Attribute("github", func() { // Should read config from the image when the attribute is not given.
377+
Description("git informations")
378+
Attribute("full_repo", String, "full github repo name", func() {
379+
Example("pingcap/tidb")
380+
})
381+
Attribute("ref", String, "git ref", func() {
382+
Example("refs/heads/master")
383+
})
384+
Attribute("commit_sha", String, "full commit SHA", func() {
385+
MinLength(40)
386+
MaxLength(40)
387+
Example("031069dfc0c70e839d996c9e1cf3d34930fc662f")
388+
})
389+
Required("full_repo", "commit_sha")
390+
})
391+
Required("image")
392+
393+
})
394+
Result(func() {
395+
Attribute("repo", String, "github full repo", func() {
396+
Meta("struct:tag:json", "repo,omitempty")
397+
Example("pingcap/tidb")
398+
})
399+
Attribute("branch", String, "github branch or tag name", func() {
400+
Meta("struct:tag:json", "branch,omitempty")
401+
Example("release-nextgen-20251011")
402+
})
403+
Attribute("sha", String, "github commit sha in the repo", func() {
404+
Meta("struct:tag:json", "sha,omitempty")
405+
Example("031069dfc0c70e839d996c9e1cf3d34930fc662f")
406+
})
407+
Attribute("imageTag", String, "image tag", func() {
408+
Meta("struct:tag:json", "imageTag,omitempty")
409+
Example("release-nextgen-20251011-031069d")
410+
})
411+
})
412+
HTTP(func() {
413+
POST("/tidbx-component-image-builds")
414+
Response(StatusOK)
415+
})
416+
})
371417
})

publisher/internal/service/gen/http/cli/publisher/cli.go

Lines changed: 32 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)