mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-01 19:53:48 +00:00
Allow to set default approval mode (#5406)
This commit is contained in:
parent
6711a674a2
commit
40e383866a
5 changed files with 29 additions and 2 deletions
|
@ -153,6 +153,12 @@ var flags = append([]cli.Flag{
|
||||||
Usage: "The default value for allowing pull requests on a repo.",
|
Usage: "The default value for allowing pull requests on a repo.",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Sources: cli.EnvVars("WOODPECKER_DEFAULT_APPROVAL_MODE"),
|
||||||
|
Name: "default-approval-mode",
|
||||||
|
Usage: "The default value for allowing pull requests on a repo.",
|
||||||
|
Value: "forks",
|
||||||
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Sources: cli.EnvVars("WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS"),
|
Sources: cli.EnvVars("WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS"),
|
||||||
Name: "default-cancel-previous-pipeline-events",
|
Name: "default-cancel-previous-pipeline-events",
|
||||||
|
|
|
@ -180,6 +180,13 @@ func setupEvilGlobals(ctx context.Context, c *cli.Command, s store.Store) (err e
|
||||||
// Pull requests
|
// Pull requests
|
||||||
server.Config.Pipeline.DefaultAllowPullRequests = c.Bool("default-allow-pull-requests")
|
server.Config.Pipeline.DefaultAllowPullRequests = c.Bool("default-allow-pull-requests")
|
||||||
|
|
||||||
|
// Approval mode
|
||||||
|
approvalMode := model.ApprovalMode(c.String("default-approval-mode"))
|
||||||
|
if !approvalMode.Valid() {
|
||||||
|
return fmt.Errorf("approval mode %s is not valid", approvalMode)
|
||||||
|
}
|
||||||
|
server.Config.Pipeline.DefaultApprovalMode = approvalMode
|
||||||
|
|
||||||
// Cloning
|
// Cloning
|
||||||
server.Config.Pipeline.DefaultClonePlugin = c.String("default-clone-plugin")
|
server.Config.Pipeline.DefaultClonePlugin = c.String("default-clone-plugin")
|
||||||
server.Config.Pipeline.TrustedClonePlugins = c.StringSlice("plugins-trusted-clone")
|
server.Config.Pipeline.TrustedClonePlugins = c.StringSlice("plugins-trusted-clone")
|
||||||
|
@ -189,7 +196,11 @@ func setupEvilGlobals(ctx context.Context, c *cli.Command, s store.Store) (err e
|
||||||
_events := c.StringSlice("default-cancel-previous-pipeline-events")
|
_events := c.StringSlice("default-cancel-previous-pipeline-events")
|
||||||
events := make([]model.WebhookEvent, 0, len(_events))
|
events := make([]model.WebhookEvent, 0, len(_events))
|
||||||
for _, v := range _events {
|
for _, v := range _events {
|
||||||
events = append(events, model.WebhookEvent(v))
|
e := model.WebhookEvent(v)
|
||||||
|
if err := e.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
events = append(events, e)
|
||||||
}
|
}
|
||||||
server.Config.Pipeline.DefaultCancelPreviousPipelineEvents = events
|
server.Config.Pipeline.DefaultCancelPreviousPipelineEvents = events
|
||||||
server.Config.Pipeline.DefaultTimeout = c.Int64("default-pipeline-timeout")
|
server.Config.Pipeline.DefaultTimeout = c.Int64("default-pipeline-timeout")
|
||||||
|
|
|
@ -808,6 +808,15 @@ The default setting for allowing pull requests on a repo.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### DEFAULT_APPROVAL_MODE
|
||||||
|
|
||||||
|
- Name: `WOODPECKER_DEFAULT_APPROVAL_MODE`
|
||||||
|
- Default: `forks`
|
||||||
|
|
||||||
|
The default setting for the approval mode on a repo. Possible values: `none`, `forks`, `pull_requests` or `all_events`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS
|
### DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS
|
||||||
|
|
||||||
- Name: `WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS`
|
- Name: `WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS`
|
||||||
|
|
|
@ -91,7 +91,7 @@ func PostRepo(c *gin.Context) {
|
||||||
repo.Update(from)
|
repo.Update(from)
|
||||||
} else {
|
} else {
|
||||||
repo = from
|
repo = from
|
||||||
repo.RequireApproval = model.RequireApprovalForks
|
repo.RequireApproval = server.Config.Pipeline.DefaultApprovalMode
|
||||||
repo.AllowPull = server.Config.Pipeline.DefaultAllowPullRequests
|
repo.AllowPull = server.Config.Pipeline.DefaultAllowPullRequests
|
||||||
repo.AllowDeploy = false
|
repo.AllowDeploy = false
|
||||||
repo.CancelPreviousPipelineEvents = server.Config.Pipeline.DefaultCancelPreviousPipelineEvents
|
repo.CancelPreviousPipelineEvents = server.Config.Pipeline.DefaultCancelPreviousPipelineEvents
|
||||||
|
|
|
@ -68,6 +68,7 @@ var Config = struct {
|
||||||
AuthenticatePublicRepos bool
|
AuthenticatePublicRepos bool
|
||||||
DefaultAllowPullRequests bool
|
DefaultAllowPullRequests bool
|
||||||
DefaultCancelPreviousPipelineEvents []model.WebhookEvent
|
DefaultCancelPreviousPipelineEvents []model.WebhookEvent
|
||||||
|
DefaultApprovalMode model.ApprovalMode
|
||||||
DefaultWorkflowLabels map[string]string
|
DefaultWorkflowLabels map[string]string
|
||||||
DefaultClonePlugin string
|
DefaultClonePlugin string
|
||||||
TrustedClonePlugins []string
|
TrustedClonePlugins []string
|
||||||
|
|
Loading…
Reference in a new issue