mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 06:08:42 +00:00
Unlimited
This commit is contained in:
parent
36b356a071
commit
f25317599a
9 changed files with 11 additions and 80 deletions
|
@ -671,7 +671,6 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
|
|||
droneserver.Config.Services.Secrets = setupSecretService(c, v)
|
||||
droneserver.Config.Services.Senders = sender.New(v, v)
|
||||
droneserver.Config.Services.Environ = setupEnvironService(c, v)
|
||||
droneserver.Config.Services.Limiter = setupLimiter(c, v)
|
||||
|
||||
if endpoint := c.String("gating-service"); endpoint != "" {
|
||||
droneserver.Config.Services.Senders = sender.NewRemote(endpoint)
|
||||
|
|
|
@ -66,10 +66,6 @@ func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService {
|
|||
return nil
|
||||
}
|
||||
|
||||
func setupLimiter(c *cli.Context, s store.Store) model.Limiter {
|
||||
return new(model.NoLimit)
|
||||
}
|
||||
|
||||
func setupPubsub(c *cli.Context) {}
|
||||
func setupStream(c *cli.Context) {}
|
||||
func setupGatingService(c *cli.Context) {}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright 2018 Drone.IO Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
// Limiter defines an interface for limiting repository creation.
|
||||
// This could be used, for example, to limit repository creation to
|
||||
// a specific organization or a specific set of users.
|
||||
type Limiter interface {
|
||||
LimitUser(*User) error
|
||||
LimitRepo(*User, *Repo) error
|
||||
LimitRepos(*User, []*Repo) []*Repo
|
||||
LimitBuild(*User, *Repo, *Build) error
|
||||
}
|
||||
|
||||
// NoLimit implements the Limiter interface without enforcing any
|
||||
// actual limits. All limiting functions are no-ops.
|
||||
type NoLimit struct{}
|
||||
|
||||
// LimitUser is a no-op for limiting user creation.
|
||||
func (NoLimit) LimitUser(*User) error { return nil }
|
||||
|
||||
// LimitRepo is a no-op for limiting repo creation.
|
||||
func (NoLimit) LimitRepo(*User, *Repo) error { return nil }
|
||||
|
||||
// LimitRepos is a no-op for limiting repository listings.
|
||||
func (NoLimit) LimitRepos(user *User, repos []*Repo) []*Repo { return repos }
|
||||
|
||||
// LimitBuild is a no-op for limiting build creation.
|
||||
func (NoLimit) LimitBuild(*User, *Repo, *Build) error { return nil }
|
|
@ -29,12 +29,12 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/drone/envsubst"
|
||||
"github.com/laszlocph/drone-oss-08/model"
|
||||
"github.com/laszlocph/drone-oss-08/remote"
|
||||
"github.com/laszlocph/drone-oss-08/shared/httputil"
|
||||
"github.com/laszlocph/drone-oss-08/shared/token"
|
||||
"github.com/laszlocph/drone-oss-08/store"
|
||||
"github.com/drone/envsubst"
|
||||
|
||||
"github.com/laszlocph/drone-oss-08/cncd/pipeline/pipeline/backend"
|
||||
"github.com/laszlocph/drone-oss-08/cncd/pipeline/pipeline/frontend"
|
||||
|
@ -212,11 +212,6 @@ func PostHook(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
if err = Config.Services.Limiter.LimitBuild(user, repo, build); err != nil {
|
||||
c.String(403, "Build blocked by limiter")
|
||||
return
|
||||
}
|
||||
|
||||
build.Trim()
|
||||
err = store.CreateBuild(c, build, build.Procs...)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,12 +19,12 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/securecookie"
|
||||
"github.com/laszlocph/drone-oss-08/model"
|
||||
"github.com/laszlocph/drone-oss-08/remote"
|
||||
"github.com/laszlocph/drone-oss-08/shared/httputil"
|
||||
"github.com/laszlocph/drone-oss-08/shared/token"
|
||||
"github.com/laszlocph/drone-oss-08/store"
|
||||
"github.com/gorilla/securecookie"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -95,11 +95,6 @@ func HandleAuth(c *gin.Context) {
|
|||
),
|
||||
}
|
||||
|
||||
if err = Config.Services.Limiter.LimitUser(u); err != nil {
|
||||
c.String(403, "User activation blocked by limiter")
|
||||
return
|
||||
}
|
||||
|
||||
// insert the user into the database
|
||||
if err := store.CreateUser(c, u); err != nil {
|
||||
logrus.Errorf("cannot insert %s. %s", u.Login, err)
|
||||
|
|
|
@ -41,11 +41,6 @@ func PostRepo(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := Config.Services.Limiter.LimitRepo(user, repo); err != nil {
|
||||
c.String(403, "Repository activation blocked by limiter")
|
||||
return
|
||||
}
|
||||
|
||||
repo.IsActive = true
|
||||
repo.UserID = user.ID
|
||||
if !repo.AllowPush && !repo.AllowPull && !repo.AllowDeploy && !repo.AllowTag {
|
||||
|
|
|
@ -55,7 +55,6 @@ var Config = struct {
|
|||
Secrets model.SecretService
|
||||
Registries model.RegistryService
|
||||
Environ model.EnvironService
|
||||
Limiter model.Limiter
|
||||
}
|
||||
Storage struct {
|
||||
// Users model.UserStore
|
||||
|
|
|
@ -28,10 +28,9 @@ type Syncer interface {
|
|||
}
|
||||
|
||||
type syncer struct {
|
||||
remote remote.Remote
|
||||
store store.Store
|
||||
perms model.PermStore
|
||||
limiter model.Limiter
|
||||
remote remote.Remote
|
||||
store store.Store
|
||||
perms model.PermStore
|
||||
}
|
||||
|
||||
func (s *syncer) Sync(user *model.User) error {
|
||||
|
@ -41,10 +40,6 @@ func (s *syncer) Sync(user *model.User) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if s.limiter != nil {
|
||||
repos = s.limiter.LimitRepos(user, repos)
|
||||
}
|
||||
|
||||
var perms []*model.Perm
|
||||
for _, repo := range repos {
|
||||
perm := model.Perm{
|
||||
|
|
|
@ -46,10 +46,9 @@ func GetFeed(c *gin.Context) {
|
|||
store.FromContext(c).UpdateUser(user)
|
||||
|
||||
sync := syncer{
|
||||
remote: remote.FromContext(c),
|
||||
store: store.FromContext(c),
|
||||
perms: store.FromContext(c),
|
||||
limiter: Config.Services.Limiter,
|
||||
remote: remote.FromContext(c),
|
||||
store: store.FromContext(c),
|
||||
perms: store.FromContext(c),
|
||||
}
|
||||
if err := sync.Sync(user); err != nil {
|
||||
logrus.Debugf("sync error: %s: %s", user.Login, err)
|
||||
|
@ -89,10 +88,9 @@ func GetRepos(c *gin.Context) {
|
|||
store.FromContext(c).UpdateUser(user)
|
||||
|
||||
sync := syncer{
|
||||
remote: remote.FromContext(c),
|
||||
store: store.FromContext(c),
|
||||
perms: store.FromContext(c),
|
||||
limiter: Config.Services.Limiter,
|
||||
remote: remote.FromContext(c),
|
||||
store: store.FromContext(c),
|
||||
perms: store.FromContext(c),
|
||||
}
|
||||
if err := sync.Sync(user); err != nil {
|
||||
logrus.Debugf("sync error: %s: %s", user.Login, err)
|
||||
|
|
Loading…
Reference in a new issue