From f644e0d49ce9008c8de19bf23cc85b223abf1fcb Mon Sep 17 00:00:00 2001 From: DaCheng Zhou <102454917+M31ancholy@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:34:18 +0800 Subject: [PATCH] refactor(server): unify api parameters to snake case (#6404) --- cmd/server/openapi/docs.go | 58 ++++++++++++++-------------- server/api/forge.go | 18 ++++----- server/api/pipeline.go | 76 ++++++++++++++++++------------------- server/api/pipeline_test.go | 12 +++--- server/api/stream.go | 6 +-- server/router/api.go | 30 +++++++-------- 6 files changed, 99 insertions(+), 101 deletions(-) diff --git a/cmd/server/openapi/docs.go b/cmd/server/openapi/docs.go index 92c6980d90..c69723471b 100644 --- a/cmd/server/openapi/docs.go +++ b/cmd/server/openapi/docs.go @@ -679,7 +679,7 @@ const docTemplate = `{ } } }, - "/forges/{forgeId}": { + "/forges/{forge_id}": { "get": { "produces": [ "application/json" @@ -699,7 +699,7 @@ const docTemplate = `{ { "type": "integer", "description": "the forge's id", - "name": "forgeId", + "name": "forge_id", "in": "path", "required": true } @@ -733,7 +733,7 @@ const docTemplate = `{ { "type": "integer", "description": "the forge's id", - "name": "forgeId", + "name": "forge_id", "in": "path", "required": true } @@ -764,7 +764,7 @@ const docTemplate = `{ { "type": "integer", "description": "the forge's id", - "name": "forgeId", + "name": "forge_id", "in": "path", "required": true }, @@ -2695,7 +2695,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/logs/{number}": { + "/repos/{repo_id}/logs/{pipeline_number}": { "delete": { "produces": [ "text/plain" @@ -2723,7 +2723,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -2735,7 +2735,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/logs/{number}/{stepID}": { + "/repos/{repo_id}/logs/{pipeline_number}/{step_id}": { "get": { "produces": [ "application/json" @@ -2763,14 +2763,14 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true }, { "type": "integer", "description": "the step id", - "name": "stepID", + "name": "step_id", "in": "path", "required": true } @@ -2786,9 +2786,7 @@ const docTemplate = `{ } } } - } - }, - "/repos/{repo_id}/logs/{number}/{stepId}": { + }, "delete": { "produces": [ "text/plain" @@ -2816,14 +2814,14 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true }, { "type": "integer", "description": "the step id", - "name": "stepId", + "name": "step_id", "in": "path", "required": true } @@ -3045,7 +3043,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}": { + "/repos/{repo_id}/pipelines/{pipeline_number}": { "get": { "produces": [ "application/json" @@ -3073,7 +3071,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline, OR 'latest'", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3115,7 +3113,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true }, @@ -3168,7 +3166,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3180,7 +3178,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}/approve": { + "/repos/{repo_id}/pipelines/{pipeline_number}/approve": { "post": { "produces": [ "application/json" @@ -3208,7 +3206,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3223,7 +3221,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}/cancel": { + "/repos/{repo_id}/pipelines/{pipeline_number}/cancel": { "post": { "produces": [ "text/plain" @@ -3251,7 +3249,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3263,7 +3261,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}/config": { + "/repos/{repo_id}/pipelines/{pipeline_number}/config": { "get": { "produces": [ "application/json" @@ -3291,7 +3289,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3309,7 +3307,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}/decline": { + "/repos/{repo_id}/pipelines/{pipeline_number}/decline": { "post": { "produces": [ "application/json" @@ -3337,7 +3335,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -3352,7 +3350,7 @@ const docTemplate = `{ } } }, - "/repos/{repo_id}/pipelines/{number}/metadata": { + "/repos/{repo_id}/pipelines/{pipeline_number}/metadata": { "get": { "produces": [ "application/json" @@ -3380,7 +3378,7 @@ const docTemplate = `{ { "type": "integer", "description": "the number of the pipeline", - "name": "number", + "name": "pipeline_number", "in": "path", "required": true } @@ -4170,7 +4168,7 @@ const docTemplate = `{ } } }, - "/stream/logs/{repo_id}/{pipeline}/{stepID}": { + "/stream/logs/{repo_id}/{pipeline}/{step_id}": { "get": { "produces": [ "text/plain" @@ -4197,7 +4195,7 @@ const docTemplate = `{ { "type": "integer", "description": "the step id", - "name": "stepID", + "name": "step_id", "in": "path", "required": true } diff --git a/server/api/forge.go b/server/api/forge.go index 79afd1f1f6..3871d1c25d 100644 --- a/server/api/forge.go +++ b/server/api/forge.go @@ -59,14 +59,14 @@ func GetForges(c *gin.Context) { // GetForge // // @Summary Get a forge -// @Router /forges/{forgeId} [get] +// @Router /forges/{forge_id} [get] // @Produce json // @Success 200 {object} Forge // @Tags Forges // @Param Authorization header string false "Insert your personal access token" default(Bearer ) -// @Param forgeId path int true "the forge's id" +// @Param forge_id path int true "the forge's id" func GetForge(c *gin.Context) { - forgeID, err := strconv.ParseInt(c.Param("forgeId"), 10, 64) + forgeID, err := strconv.ParseInt(c.Param("forge_id"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -89,12 +89,12 @@ func GetForge(c *gin.Context) { // PatchForge // // @Summary Update a forge -// @Router /forges/{forgeId} [patch] +// @Router /forges/{forge_id} [patch] // @Produce json // @Success 200 {object} Forge // @Tags Forges // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param forgeId path int true "the forge's id" +// @Param forge_id path int true "the forge's id" // @Param forgeData body ForgeWithOAuthClientSecret true "the forge's data" func PatchForge(c *gin.Context) { _store := store.FromContext(c) @@ -106,7 +106,7 @@ func PatchForge(c *gin.Context) { return } - forgeID, err := strconv.ParseInt(c.Param("forgeId"), 10, 64) + forgeID, err := strconv.ParseInt(c.Param("forge_id"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -173,16 +173,16 @@ func PostForge(c *gin.Context) { // DeleteForge // // @Summary Delete a forge -// @Router /forges/{forgeId} [delete] +// @Router /forges/{forge_id} [delete] // @Produce plain // @Success 200 // @Tags Forges // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param forgeId path int true "the forge's id" +// @Param forge_id path int true "the forge's id" func DeleteForge(c *gin.Context) { _store := store.FromContext(c) - forgeID, err := strconv.ParseInt(c.Param("forgeId"), 10, 64) + forgeID, err := strconv.ParseInt(c.Param("forge_id"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return diff --git a/server/api/pipeline.go b/server/api/pipeline.go index a2548d91de..0feac0091b 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -191,18 +191,18 @@ func GetPipelines(c *gin.Context) { // DeletePipeline // // @Summary Delete a pipeline -// @Router /repos/{repo_id}/pipelines/{number} [delete] +// @Router /repos/{repo_id}/pipelines/{pipeline_number} [delete] // @Produce plain // @Success 204 // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func DeletePipeline(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - num, err := strconv.ParseInt(c.Param("number"), 10, 64) + num, err := strconv.ParseInt(c.Param("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -231,22 +231,22 @@ func DeletePipeline(c *gin.Context) { // GetPipeline // // @Summary Get a repositories pipeline -// @Router /repos/{repo_id}/pipelines/{number} [get] +// @Router /repos/{repo_id}/pipelines/{pipeline_number} [get] // @Produce json // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline, OR 'latest'" +// @Param pipeline_number path int true "the number of the pipeline, OR 'latest'" func GetPipeline(c *gin.Context) { _store := store.FromContext(c) - if c.Param("number") == "latest" { + if c.Param("pipeline_number") == "latest" { GetPipelineLastByBranch(c) return } repo := session.Repo(c) - num, err := strconv.ParseInt(c.Param("number"), 10, 64) + num, err := strconv.ParseInt(c.Param("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -286,21 +286,21 @@ func GetPipelineLastByBranch(c *gin.Context) { // GetStepLogs // // @Summary Get logs for a pipeline step -// @Router /repos/{repo_id}/logs/{number}/{stepID} [get] +// @Router /repos/{repo_id}/logs/{pipeline_number}/{step_id} [get] // @Produce json // @Success 200 {array} LogEntry // @Tags Pipeline logs // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" -// @Param stepID path int true "the step id" +// @Param pipeline_number path int true "the number of the pipeline" +// @Param step_id path int true "the step id" func GetStepLogs(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) // parse the pipeline number and step sequence number from // the request parameter. - num, err := strconv.ParseInt(c.Params.ByName("number"), 10, 64) + num, err := strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -312,7 +312,7 @@ func GetStepLogs(c *gin.Context) { return } - stepID, err := strconv.ParseInt(c.Params.ByName("stepId"), 10, 64) + stepID, err := strconv.ParseInt(c.Params.ByName("step_id"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -342,19 +342,19 @@ func GetStepLogs(c *gin.Context) { // DeleteStepLogs // // @Summary Delete step logs of a pipeline -// @Router /repos/{repo_id}/logs/{number}/{stepId} [delete] +// @Router /repos/{repo_id}/logs/{pipeline_number}/{step_id} [delete] // @Produce plain // @Success 204 // @Tags Pipeline logs // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" -// @Param stepId path int true "the step id" +// @Param pipeline_number path int true "the number of the pipeline" +// @Param step_id path int true "the step id" func DeleteStepLogs(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - pipelineNumber, err := strconv.ParseInt(c.Params.ByName("number"), 10, 64) + pipelineNumber, err := strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -366,7 +366,7 @@ func DeleteStepLogs(c *gin.Context) { return } - stepID, err := strconv.ParseInt(c.Params.ByName("stepId"), 10, 64) + stepID, err := strconv.ParseInt(c.Params.ByName("step_id"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -402,17 +402,17 @@ func DeleteStepLogs(c *gin.Context) { // GetPipelineConfig // // @Summary Get configuration files for a pipeline -// @Router /repos/{repo_id}/pipelines/{number}/config [get] +// @Router /repos/{repo_id}/pipelines/{pipeline_number}/config [get] // @Produce json // @Success 200 {array} Config // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func GetPipelineConfig(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - num, err := strconv.ParseInt(c.Param("number"), 10, 64) + num, err := strconv.ParseInt(c.Param("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -436,16 +436,16 @@ func GetPipelineConfig(c *gin.Context) { // GetPipelineMetadata // // @Summary Get metadata for a pipeline or a specific workflow, including previous pipeline info -// @Router /repos/{repo_id}/pipelines/{number}/metadata [get] +// @Router /repos/{repo_id}/pipelines/{pipeline_number}/metadata [get] // @Produce json // @Success 200 {object} metadata.Metadata // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func GetPipelineMetadata(c *gin.Context) { repo := session.Repo(c) - num, err := strconv.ParseInt(c.Param("number"), 10, 64) + num, err := strconv.ParseInt(c.Param("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -477,13 +477,13 @@ func GetPipelineMetadata(c *gin.Context) { // CancelPipeline // // @Summary Cancel a pipeline -// @Router /repos/{repo_id}/pipelines/{number}/cancel [post] +// @Router /repos/{repo_id}/pipelines/{pipeline_number}/cancel [post] // @Produce plain // @Success 200 // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func CancelPipeline(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) @@ -495,7 +495,7 @@ func CancelPipeline(c *gin.Context) { return } - num, _ := strconv.ParseInt(c.Params.ByName("number"), 10, 64) + num, _ := strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) pl, err := _store.GetPipelineNumber(repo, num) if err != nil { @@ -515,19 +515,19 @@ func CancelPipeline(c *gin.Context) { // PostApproval // // @Summary Approve and start a pipeline -// @Router /repos/{repo_id}/pipelines/{number}/approve [post] +// @Router /repos/{repo_id}/pipelines/{pipeline_number}/approve [post] // @Produce json // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func PostApproval(c *gin.Context) { var ( _store = store.FromContext(c) repo = session.Repo(c) user = session.User(c) - num, _ = strconv.ParseInt(c.Params.ByName("number"), 10, 64) + num, _ = strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) ) pl, err := _store.GetPipelineNumber(repo, num) @@ -547,19 +547,19 @@ func PostApproval(c *gin.Context) { // PostDecline // // @Summary Decline a pipeline -// @Router /repos/{repo_id}/pipelines/{number}/decline [post] +// @Router /repos/{repo_id}/pipelines/{pipeline_number}/decline [post] // @Produce json // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func PostDecline(c *gin.Context) { var ( _store = store.FromContext(c) repo = session.Repo(c) user = session.User(c) - num, _ = strconv.ParseInt(c.Params.ByName("number"), 10, 64) + num, _ = strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) ) pl, err := _store.GetPipelineNumber(repo, num) @@ -597,20 +597,20 @@ func GetPipelineQueue(c *gin.Context) { // // @Summary Restart a pipeline // @Description Restarts a pipeline optional with altered event, deploy or environment -// @Router /repos/{repo_id}/pipelines/{number} [post] +// @Router /repos/{repo_id}/pipelines/{pipeline_number} [post] // @Produce json // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" // @Param event query string false "override the event type" // @Param deploy_to query string false "override the target deploy value" func PostPipeline(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - num, err := strconv.ParseInt(c.Param("number"), 10, 64) + num, err := strconv.ParseInt(c.Param("pipeline_number"), 10, 64) if err != nil { _ = c.AbortWithError(http.StatusBadRequest, err) return @@ -679,18 +679,18 @@ func PostPipeline(c *gin.Context) { // DeletePipelineLogs // // @Summary Deletes all logs of a pipeline -// @Router /repos/{repo_id}/logs/{number} [delete] +// @Router /repos/{repo_id}/logs/{pipeline_number} [delete] // @Produce plain // @Success 204 // @Tags Pipeline logs // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" +// @Param pipeline_number path int true "the number of the pipeline" func DeletePipelineLogs(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - num, _ := strconv.ParseInt(c.Params.ByName("number"), 10, 64) + num, _ := strconv.ParseInt(c.Params.ByName("pipeline_number"), 10, 64) pl, err := _store.GetPipelineNumber(repo, num) if err != nil { diff --git a/server/api/pipeline_test.go b/server/api/pipeline_test.go index 2c14d480a7..6f96cc96ca 100644 --- a/server/api/pipeline_test.go +++ b/server/api/pipeline_test.go @@ -134,7 +134,7 @@ func TestDeletePipeline(t *testing.T) { c, _ := gin.CreateTestContext(httptest.NewRecorder()) c.Set("store", mockStore) - c.Params = gin.Params{{Key: "number", Value: "2"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "2"}} DeletePipeline(c) @@ -160,7 +160,7 @@ func TestDeletePipeline(t *testing.T) { c, _ := gin.CreateTestContext(httptest.NewRecorder()) c.Set("store", mockStore) - c.Params = gin.Params{{Key: "number", Value: "2"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "2"}} DeletePipeline(c) @@ -197,7 +197,7 @@ func TestGetPipelineMetadata(t *testing.T) { t.Run("should get pipeline metadata", func(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) - c.Params = gin.Params{{Key: "number", Value: "2"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "2"}} c.Set("store", mockStore) c.Set("forge", mockForge) c.Set("repo", fakeRepo) @@ -218,7 +218,7 @@ func TestGetPipelineMetadata(t *testing.T) { t.Run("should return bad request for invalid pipeline number", func(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) - c.Params = gin.Params{{Key: "number", Value: "invalid"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "invalid"}} GetPipelineMetadata(c) @@ -231,7 +231,7 @@ func TestGetPipelineMetadata(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) - c.Params = gin.Params{{Key: "number", Value: "3"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "3"}} c.Set("store", mockStore) c.Set("repo", fakeRepo) @@ -271,7 +271,7 @@ func TestCancelPipeline(t *testing.T) { c.Set("store", mockStore) c.Set("repo", fakeRepo) c.Set("user", fakeUser) - c.Params = gin.Params{{Key: "number", Value: "2"}} + c.Params = gin.Params{{Key: "pipeline_number", Value: "2"}} CancelPipeline(c) diff --git a/server/api/stream.go b/server/api/stream.go index 9c445c7958..7d0a667c22 100644 --- a/server/api/stream.go +++ b/server/api/stream.go @@ -130,13 +130,13 @@ func EventStreamSSE(c *gin.Context) { // LogStreamSSE // // @Summary Stream logs of a pipeline step -// @Router /stream/logs/{repo_id}/{pipeline}/{stepID} [get] +// @Router /stream/logs/{repo_id}/{pipeline}/{step_id} [get] // @Produce plain // @Success 200 // @Tags Pipeline logs // @Param repo_id path int true "the repository id" // @Param pipeline path int true "the number of the pipeline" -// @Param stepID path int true "the step id" +// @Param step_id path int true "the step id" func LogStreamSSE(c *gin.Context) { c.Header("Content-Type", "text/event-stream") c.Header("Cache-Control", "no-cache") @@ -170,7 +170,7 @@ func LogStreamSSE(c *gin.Context) { return } - stepID, err := strconv.ParseInt(c.Param("stepId"), 10, 64) + stepID, err := strconv.ParseInt(c.Param("step_id"), 10, 64) if err != nil { log.Debug().Err(err).Msg("step id invalid") logWriteStringErr(io.WriteString(rw, "event: error\ndata: step id invalid\n\n")) diff --git a/server/router/api.go b/server/router/api.go index 092be0f48f..2b718f5a51 100644 --- a/server/router/api.go +++ b/server/router/api.go @@ -109,22 +109,22 @@ func apiRoutes(e *gin.RouterGroup) { repo.GET("/pipelines", api.GetPipelines) repo.POST("/pipelines", session.MustPush, api.CreatePipeline) - repo.DELETE("/pipelines/:number", session.MustRepoAdmin(), api.DeletePipeline) - repo.GET("/pipelines/:number", api.GetPipeline) - repo.GET("/pipelines/:number/config", api.GetPipelineConfig) - repo.GET("/pipelines/:number/metadata", session.MustPush, api.GetPipelineMetadata) + repo.DELETE("/pipelines/:pipeline_number", session.MustRepoAdmin(), api.DeletePipeline) + repo.GET("/pipelines/:pipeline_number", api.GetPipeline) + repo.GET("/pipelines/:pipeline_number/config", api.GetPipelineConfig) + repo.GET("/pipelines/:pipeline_number/metadata", session.MustPush, api.GetPipelineMetadata) // requires push permissions - repo.POST("/pipelines/:number", session.MustPush, api.PostPipeline) - repo.POST("/pipelines/:number/cancel", session.MustPush, api.CancelPipeline) - repo.POST("/pipelines/:number/approve", session.MustPush, api.PostApproval) - repo.POST("/pipelines/:number/decline", session.MustPush, api.PostDecline) + repo.POST("/pipelines/:pipeline_number", session.MustPush, api.PostPipeline) + repo.POST("/pipelines/:pipeline_number/cancel", session.MustPush, api.CancelPipeline) + repo.POST("/pipelines/:pipeline_number/approve", session.MustPush, api.PostApproval) + repo.POST("/pipelines/:pipeline_number/decline", session.MustPush, api.PostDecline) - repo.GET("/logs/:number/:stepId", api.GetStepLogs) - repo.DELETE("/logs/:number/:stepId", session.MustPush, api.DeleteStepLogs) + repo.GET("/logs/:pipeline_number/:step_id", api.GetStepLogs) + repo.DELETE("/logs/:pipeline_number/:step_id", session.MustPush, api.DeleteStepLogs) // requires push permissions - repo.DELETE("/logs/:number", session.MustPush, api.DeletePipelineLogs) + repo.DELETE("/logs/:pipeline_number", session.MustPush, api.DeletePipelineLogs) // requires push permissions repo.GET("/secrets", session.MustPush, api.GetSecretList) @@ -234,13 +234,13 @@ func apiRoutes(e *gin.RouterGroup) { } apiBase.GET("/forges", api.GetForges) - apiBase.GET("/forges/:forgeId", api.GetForge) + apiBase.GET("/forges/:forge_id", api.GetForge) forgeBase := apiBase.Group("/forges") { forgeBase.Use(session.MustAdmin()) forgeBase.POST("", api.PostForge) - forgeBase.PATCH("/:forgeId", api.PatchForge) - forgeBase.DELETE("/:forgeId", api.DeleteForge) + forgeBase.PATCH("/:forge_id", api.PatchForge) + forgeBase.DELETE("/:forge_id", api.DeleteForge) } apiBase.GET("/signature/public-key", api.GetSignaturePublicKey) @@ -249,7 +249,7 @@ func apiRoutes(e *gin.RouterGroup) { stream := apiBase.Group("/stream") { - stream.GET("/logs/:repo_id/:pipeline/:stepId", + stream.GET("/logs/:repo_id/:pipeline/:step_id", session.SetRepo(), session.SetPerm(), session.MustPull,