From 5045f1e4315b09142dc69a83bda66a2d16f9cc78 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:21:05 +0200 Subject: [PATCH] Remove deprecated API paths (#2639) --- cmd/server/docs/docs.go | 97 ++++++++++++++++++++++---------------- docs/docs/91-migrations.md | 5 +- server/api/pipeline.go | 2 +- server/api/stream.go | 14 ++++-- server/router/api.go | 9 ---- 5 files changed, 70 insertions(+), 57 deletions(-) diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index e48fcbb21..73a867e2c 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -743,45 +743,6 @@ const docTemplate = `{ } } }, - "/logs/{repo_id}/{pipeline}/{stepID}": { - "get": { - "produces": [ - "text/plain" - ], - "tags": [ - "Pipeline logs" - ], - "summary": "Log stream", - "parameters": [ - { - "type": "integer", - "description": "the repository id", - "name": "repo_id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "the number of the pipeline", - "name": "pipeline", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "the step id", - "name": "stepID", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, "/org/lookup/{org_full_name}": { "get": { "produces": [ @@ -1968,7 +1929,7 @@ const docTemplate = `{ } }, "/repos/{repo_id}/logs/{number}": { - "post": { + "delete": { "produces": [ "text/plain" ], @@ -3274,6 +3235,62 @@ const docTemplate = `{ } } }, + "/stream/events": { + "get": { + "description": "event source streaming for compatibility with quic and http2", + "produces": [ + "text/plain" + ], + "tags": [ + "Events" + ], + "summary": "Event stream", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/stream/logs/{repo_id}/{pipeline}/{stepID}": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "Pipeline logs" + ], + "summary": "Log stream", + "parameters": [ + { + "type": "integer", + "description": "the repository id", + "name": "repo_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "the number of the pipeline", + "name": "pipeline", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "the step id", + "name": "stepID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/user": { "get": { "produces": [ diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index ef7d51223..ad0c964c9 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -10,11 +10,12 @@ Some versions need some changes to the server configuration or the pipeline conf - Deprecated `platform:` filter in favor of `labels:`, [read more](./20-usage/20-workflow-syntax.md#filter-by-platform) - Removed `build` alias for `pipeline` command in CLI - Removed `ssh` backend. Use an agent directly on the SSH machine using the `local` backend. +- Removed `/hook` and `/stream` API paths in favor of `/api/(hook|stream)`. You may need to use the "Repair repository" button in the repo settings or "Repair all" in the admin settings to recreate the forge hook. ## 1.0.0 -- The signature used to verify extensions calls (like those used for the [config-extension](./30-administration/100-external-configuration-api.md)) done by the Woodpecker server switched from using a shared-secret HMac to an ed25519 key-pair. Read more about it at the [config-extensions](./30-administration/100-external-configuration-api.md) documentation. -- Refactored support of old agent filter labels and expression. Learn how to use the new [filter](./20-usage/20-workflow-syntax.md#labels) +- The signature used to verify extension calls (like those used for the [config-extension](./30-administration/100-external-configuration-api.md)) done by the Woodpecker server switched from using a shared-secret HMac to an ed25519 key-pair. Read more about it at the [config-extensions](./30-administration/100-external-configuration-api.md) documentation. +- Refactored support for old agent filter labels and expressions. Learn how to use the new [filter](./20-usage/20-workflow-syntax.md#labels) - Renamed step environment variable `CI_SYSTEM_ARCH` to `CI_SYSTEM_PLATFORM`. Same applies for the cli exec variable. - Renamed environment variables `CI_BUILD_*` and `CI_PREV_BUILD_*` to `CI_PIPELINE_*` and `CI_PREV_PIPELINE_*`, old ones are still available but deprecated - Renamed environment variables `CI_JOB_*` to `CI_STEP_*`, old ones are still available but deprecated diff --git a/server/api/pipeline.go b/server/api/pipeline.go index a4cdb6410..2d29eda9b 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -453,7 +453,7 @@ func PostPipeline(c *gin.Context) { // DeletePipelineLogs // // @Summary Deletes log -// @Router /repos/{repo_id}/logs/{number} [post] +// @Router /repos/{repo_id}/logs/{number} [delete] // @Produce plain // @Success 204 // @Tags Pipeline logs diff --git a/server/api/stream.go b/server/api/stream.go index 8eb004d9b..0910f8b35 100644 --- a/server/api/stream.go +++ b/server/api/stream.go @@ -34,10 +34,14 @@ import ( "github.com/woodpecker-ci/woodpecker/server/store" ) +// EventStreamSSE // -// event source streaming for compatibility with quic and http2 -// - +// @Summary Event stream +// @Description event source streaming for compatibility with quic and http2 +// @Router /stream/events [get] +// @Produce plain +// @Success 200 +// @Tags Events func EventStreamSSE(c *gin.Context) { c.Header("Content-Type", "text/event-stream") c.Header("Cache-Control", "no-cache") @@ -118,10 +122,10 @@ func EventStreamSSE(c *gin.Context) { } } -// LogStream +// LogStreamSSE // // @Summary Log stream -// @Router /logs/{repo_id}/{pipeline}/{stepID} [get] +// @Router /stream/logs/{repo_id}/{pipeline}/{stepID} [get] // @Produce plain // @Success 200 // @Tags Pipeline logs diff --git a/server/router/api.go b/server/router/api.go index 0a22f9e9c..f1a33beca 100644 --- a/server/router/api.go +++ b/server/router/api.go @@ -224,13 +224,4 @@ func apiRoutes(e *gin.RouterGroup) { } } } - - // TODO: remove /hook in favor of /api/hook - e.POST("/hook", api.PostHook) - - // TODO: move to /api/stream - sse := e.Group("/stream") - { - sse.GET("/events", api.EventStreamSSE) - } }