mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-02-03 17:47:24 +00:00
Move open registration setting into remote plugins
...so that it's possible to enable or disable open registration on a per-remote basis. For example, the `DRONE_REGISTRATION_OPEN` environment variable now becomes `DRONE_GITHUB_OPEN` when using GitHub as a remote. The default for open registration in this commit is `false` (disabled), which matches the existing behaviour. This is useful if you need to support both public and private remotes, e.g. GitHub.com and GitHub Enterprise, where you trust all of the private users and want to allow open registration for those but would not want all GitHub.com users to run builds on your server. Tested with GitHub and GitLab.
This commit is contained in:
@@ -13,12 +13,14 @@ import (
|
||||
type Gitlab struct {
|
||||
url string
|
||||
SkipVerify bool
|
||||
Open bool
|
||||
}
|
||||
|
||||
func New(url string, skipVerify bool) *Gitlab {
|
||||
func New(url string, skipVerify, open bool) *Gitlab {
|
||||
return &Gitlab{
|
||||
url: url,
|
||||
SkipVerify: skipVerify,
|
||||
Open: open,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,3 +193,7 @@ func (r *Gitlab) ParseHook(req *http.Request) (*model.Hook, error) {
|
||||
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
func (r *Gitlab) OpenRegistration() bool {
|
||||
return r.Open
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func Test_Github(t *testing.T) {
|
||||
var server = testdata.NewServer()
|
||||
defer server.Close()
|
||||
|
||||
var gitlab = New(server.URL, false)
|
||||
var gitlab = New(server.URL, false, false)
|
||||
var user = model.User{
|
||||
Access: "e3b0c44298fc1c149afbf4c8996fb",
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
var (
|
||||
gitlabURL = config.String("gitlab-url", "")
|
||||
gitlabSkipVerify = config.Bool("gitlab-skip-verify", false)
|
||||
gitlabOpen = config.Bool("gitlab-open", false)
|
||||
)
|
||||
|
||||
// Registers the Gitlab plugin using the default
|
||||
@@ -21,6 +22,7 @@ func Register() {
|
||||
New(
|
||||
*gitlabURL,
|
||||
*gitlabSkipVerify,
|
||||
*gitlabOpen,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user