Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tekton via cloud event #67

Merged
merged 26 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tibuild/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ test:
build.server: swagger test
go build -o ${GO_BINARY} ${TIBUILD_MAIN_FILE}

server:
go run ${TIBUILD_MAIN_FILE}

# =============================================================================
# The following are common deployment commands
Expand Down
10 changes: 9 additions & 1 deletion tibuild/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/PingCAP-QE/ee-apps/tibuild/internal/controller"
controllers "github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/controller"
"github.com/PingCAP-QE/ee-apps/tibuild/pkg/rest/service"
events "github.com/PingCAP-QE/ee-apps/tibuild/pkg/webhook/handler"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use origin name handler


_ "github.com/PingCAP-QE/ee-apps/tibuild/docs"
)
Expand Down Expand Up @@ -102,7 +103,8 @@ func routeRestAPI(router *gin.Engine, cfg *configs.ConfigYaml) {
panic(err)
}
devBuildGroup := apiGroup.Group("/devbuilds")
devBuildHandler := controllers.NewDevBuildHandler(context.Background(), jenkins, database.DBConn.DB, cfg.RestApiSecret)
devBuildServer := controllers.NewDevBuildServer(jenkins, database.DBConn.DB, cfg.CloudEvent.Endpoint)
devBuildHandler := controllers.NewDevBuildHandler(devBuildServer, cfg.RestApiSecret)
{
devBuildGroup.POST("", devBuildHandler.Create)
devBuildGroup.GET("", devBuildHandler.List)
Expand All @@ -116,4 +118,10 @@ func routeRestAPI(router *gin.Engine, cfg *configs.ConfigYaml) {
{
artifactGroup.POST("/sync-image", artifactHelper.SyncImage)
}

event := events.NewHandler(devBuildServer)
eventsGroup := apiGroup.Group("/event")
{
eventsGroup.POST("", event.Receive)
}
}
3 changes: 3 additions & 0 deletions tibuild/commons/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type ConfigYaml struct {
}

RestApiSecret RestApiSecret
CloudEvent struct {
Endpoint string
}
}

type RestApiSecret struct {
Expand Down
115 changes: 115 additions & 0 deletions tibuild/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ const docTemplate = `{
"component": {
"type": "string"
},
"oras": {
"$ref": "#/definitions/service.OrasFile"
},
"platform": {
"type": "string"
},
Expand Down Expand Up @@ -461,6 +464,9 @@ const docTemplate = `{
"features": {
"type": "string"
},
"gitHash": {
"type": "string"
},
"gitRef": {
"type": "string"
},
Expand All @@ -473,6 +479,9 @@ const docTemplate = `{
"isPushGCR": {
"type": "boolean"
},
"pipelineEngine": {
"$ref": "#/definitions/service.PipelineEngine"
},
"pluginGitRef": {
"type": "string"
},
Expand Down Expand Up @@ -516,6 +525,9 @@ const docTemplate = `{
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
},
"tektonStatus": {
"$ref": "#/definitions/service.TektonStatus"
}
}
},
Expand All @@ -541,6 +553,48 @@ const docTemplate = `{
}
}
},
"service.OrasArtifact": {
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"type": "string"
}
},
"repo": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"service.OrasFile": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"repo": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"service.PipelineEngine": {
"type": "string",
"enum": [
"jenkins",
"tekton"
],
"x-enum-varnames": [
"JenkinsEngine",
"TektonEngine"
]
},
"service.Product": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -614,6 +668,67 @@ const docTemplate = `{
"type": "string"
}
}
},
"service.TektonPipeline": {
"type": "object",
"properties": {
"gitHash": {
"type": "string"
},
"images": {
"type": "array",
"items": {
"$ref": "#/definitions/service.ImageArtifact"
}
},
"name": {
"type": "string"
},
"orasArtifacts": {
"type": "array",
"items": {
"$ref": "#/definitions/service.OrasArtifact"
}
},
"pipelineEndAt": {
"type": "string"
},
"pipelineStartAt": {
"type": "string"
},
"platform": {
"type": "string"
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
},
"url": {
"type": "string"
}
}
},
"service.TektonStatus": {
"type": "object",
"properties": {
"buildReport": {
"$ref": "#/definitions/service.BuildReport"
},
"pipelineEndAt": {
"type": "string"
},
"pipelineStartAt": {
"type": "string"
},
"pipelines": {
"type": "array",
"items": {
"$ref": "#/definitions/service.TektonPipeline"
}
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
}
}
}
}
}`
Expand Down
115 changes: 115 additions & 0 deletions tibuild/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@
"component": {
"type": "string"
},
"oras": {
"$ref": "#/definitions/service.OrasFile"
},
"platform": {
"type": "string"
},
Expand Down Expand Up @@ -449,6 +452,9 @@
"features": {
"type": "string"
},
"gitHash": {
"type": "string"
},
"gitRef": {
"type": "string"
},
Expand All @@ -461,6 +467,9 @@
"isPushGCR": {
"type": "boolean"
},
"pipelineEngine": {
"$ref": "#/definitions/service.PipelineEngine"
},
"pluginGitRef": {
"type": "string"
},
Expand Down Expand Up @@ -504,6 +513,9 @@
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
},
"tektonStatus": {
"$ref": "#/definitions/service.TektonStatus"
}
}
},
Expand All @@ -529,6 +541,48 @@
}
}
},
"service.OrasArtifact": {
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"type": "string"
}
},
"repo": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"service.OrasFile": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"repo": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"service.PipelineEngine": {
"type": "string",
"enum": [
"jenkins",
"tekton"
],
"x-enum-varnames": [
"JenkinsEngine",
"TektonEngine"
]
},
"service.Product": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -602,6 +656,67 @@
"type": "string"
}
}
},
"service.TektonPipeline": {
"type": "object",
"properties": {
"gitHash": {
"type": "string"
},
"images": {
"type": "array",
"items": {
"$ref": "#/definitions/service.ImageArtifact"
}
},
"name": {
"type": "string"
},
"orasArtifacts": {
"type": "array",
"items": {
"$ref": "#/definitions/service.OrasArtifact"
}
},
"pipelineEndAt": {
"type": "string"
},
"pipelineStartAt": {
"type": "string"
},
"platform": {
"type": "string"
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
},
"url": {
"type": "string"
}
}
},
"service.TektonStatus": {
"type": "object",
"properties": {
"buildReport": {
"$ref": "#/definitions/service.BuildReport"
},
"pipelineEndAt": {
"type": "string"
},
"pipelineStartAt": {
"type": "string"
},
"pipelines": {
"type": "array",
"items": {
"$ref": "#/definitions/service.TektonPipeline"
}
},
"status": {
"$ref": "#/definitions/service.BuildStatus"
}
}
}
}
}
Loading
Loading