mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 01:41:02 +00:00
Remove various deprecations (#4017)
This commit is contained in:
parent
948201f12c
commit
92ff320429
7 changed files with 14 additions and 81 deletions
|
@ -29,7 +29,6 @@ import (
|
|||
"go.woodpecker-ci.org/woodpecker/v2/cli/org"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/pipeline"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/repo"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/repo/registry"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/secret"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/setup"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/cli/update"
|
||||
|
@ -57,8 +56,6 @@ func newApp() *cli.Command {
|
|||
deploy.Command,
|
||||
exec.Command,
|
||||
info.Command,
|
||||
// TODO: Remove in 3.x
|
||||
registry.Command,
|
||||
secret.Command,
|
||||
user.Command,
|
||||
lint.Command,
|
||||
|
|
|
@ -81,12 +81,11 @@ WOODPECKER_CONFIG_SERVICE_ENDPOINT=https://example.com/ciconfig
|
|||
"updated_at": 0,
|
||||
"verified": false
|
||||
},
|
||||
"configs": [
|
||||
{
|
||||
"name": ".woodpecker.yaml",
|
||||
"data": "steps:\n - name: backend\n image: alpine\n commands:\n - echo \"Hello there from Repo (.woodpecker.yaml)\"\n"
|
||||
}
|
||||
]
|
||||
"netrc": {
|
||||
"machine": "https://example.com",
|
||||
"login": "user",
|
||||
"password": "password"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ Some versions need some changes to the server configuration or the pipeline conf
|
|||
- Renamed `start_time`, `end_time`, `created_at`, `started_at`, `finished_at` and `reviewed_at` JSON fields to `started`, `finished`, `created`, `started`, `finished`, `reviewed`
|
||||
- Update all webhooks by pressing the "Repair all" button in the admin settings as the webhook token claims have changed
|
||||
- Crons now use standard Linux syntax without seconds
|
||||
- Replaced `configs` object by `netrc` in external configuration APIs
|
||||
- Removed old API routes: `registry/` -> `registries`, `/authorize/token`
|
||||
- Replaced `registry` command with `repo registry` in cli
|
||||
|
||||
## 2.0.0
|
||||
|
||||
|
|
|
@ -297,54 +297,3 @@ func GetLogout(c *gin.Context) {
|
|||
httputil.DelCookie(c.Writer, c.Request, "user_last")
|
||||
c.Redirect(http.StatusSeeOther, server.Config.Server.RootPath+"/")
|
||||
}
|
||||
|
||||
// TODO: remove in 3.0
|
||||
func DeprecatedGetLoginToken(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
|
||||
_forge, err := server.Config.Services.Manager.ForgeByID(1)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Cannot get main forge")
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
in := &tokenPayload{}
|
||||
err = c.Bind(in)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
login, err := _forge.Auth(c, in.Access, in.Refresh)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return
|
||||
}
|
||||
|
||||
user, err := _store.GetUserLogin(login)
|
||||
if err != nil {
|
||||
handleDBError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
exp := time.Now().Add(server.Config.Server.SessionExpires).Unix()
|
||||
newToken := token.New(token.SessToken)
|
||||
newToken.Set("user-id", strconv.FormatInt(user.ID, 10))
|
||||
tokenStr, err := newToken.SignExpires(user.Hash, exp)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, &tokenPayload{
|
||||
Access: tokenStr,
|
||||
Expires: exp - time.Now().Unix(),
|
||||
})
|
||||
}
|
||||
|
||||
type tokenPayload struct {
|
||||
Access string `json:"access_token,omitempty"`
|
||||
Refresh string `json:"refresh_token,omitempty"`
|
||||
Expires int64 `json:"expires_in,omitempty"`
|
||||
}
|
||||
|
|
|
@ -129,13 +129,6 @@ func apiRoutes(e *gin.RouterGroup) {
|
|||
repo.PATCH("/registries/:registry", session.MustPush, api.PatchRegistry)
|
||||
repo.DELETE("/registries/:registry", session.MustPush, api.DeleteRegistry)
|
||||
|
||||
// TODO: remove with 3.x
|
||||
repo.GET("/registry", session.MustPush, api.GetRegistryList)
|
||||
repo.POST("/registry", session.MustPush, api.PostRegistry)
|
||||
repo.GET("/registry/:registry", session.MustPush, api.GetRegistry)
|
||||
repo.PATCH("/registry/:registry", session.MustPush, api.PatchRegistry)
|
||||
repo.DELETE("/registry/:registry", session.MustPush, api.DeleteRegistry)
|
||||
|
||||
// requires push permissions
|
||||
repo.GET("/cron", session.MustPush, api.GetCronList)
|
||||
repo.POST("/cron", session.MustPush, api.PostCron)
|
||||
|
|
|
@ -62,7 +62,6 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H
|
|||
{
|
||||
auth.GET("", api.HandleAuth)
|
||||
auth.POST("", api.HandleAuth)
|
||||
auth.POST("/token", api.DeprecatedGetLoginToken)
|
||||
}
|
||||
|
||||
base.GET("/metrics", metrics.PromHandler())
|
||||
|
|
|
@ -38,10 +38,9 @@ type configData struct {
|
|||
}
|
||||
|
||||
type requestStructure struct {
|
||||
Repo *model.Repo `json:"repo"`
|
||||
Pipeline *model.Pipeline `json:"pipeline"`
|
||||
Netrc *model.Netrc `json:"netrc"`
|
||||
Configuration []*configData `json:"configs"` // TODO: deprecate in favor of netrc and remove in next major release
|
||||
Repo *model.Repo `json:"repo"`
|
||||
Pipeline *model.Pipeline `json:"pipeline"`
|
||||
Netrc *model.Netrc `json:"netrc"`
|
||||
}
|
||||
|
||||
type responseStructure struct {
|
||||
|
@ -53,11 +52,6 @@ func NewHTTP(endpoint string, privateKey ed25519.PrivateKey) Service {
|
|||
}
|
||||
|
||||
func (h *http) Fetch(ctx context.Context, forge forge.Forge, user *model.User, repo *model.Repo, pipeline *model.Pipeline, oldConfigData []*types.FileMeta, _ bool) ([]*types.FileMeta, error) {
|
||||
currentConfigs := make([]*configData, len(oldConfigData))
|
||||
for i, pipe := range oldConfigData {
|
||||
currentConfigs[i] = &configData{Name: pipe.Name, Data: string(pipe.Data)}
|
||||
}
|
||||
|
||||
netrc, err := forge.Netrc(user, repo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get Netrc data from forge: %w", err)
|
||||
|
@ -65,10 +59,9 @@ func (h *http) Fetch(ctx context.Context, forge forge.Forge, user *model.User, r
|
|||
|
||||
response := new(responseStructure)
|
||||
body := requestStructure{
|
||||
Repo: repo,
|
||||
Pipeline: pipeline,
|
||||
Configuration: currentConfigs,
|
||||
Netrc: netrc,
|
||||
Repo: repo,
|
||||
Pipeline: pipeline,
|
||||
Netrc: netrc,
|
||||
}
|
||||
|
||||
status, err := utils.Send(ctx, net_http.MethodPost, h.endpoint, h.privateKey, body, response)
|
||||
|
|
Loading…
Reference in a new issue