mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 02:11:01 +00:00
Remove push, tag and deployment webhook filters (#281)
- remove `AllowPush`, `AllowTag`, `AllowDeploy` options. - keep `AllowPullRequest` option and disable it by default --- close #265 close #243
This commit is contained in:
parent
387760ccbf
commit
894df351ee
19 changed files with 187 additions and 175 deletions
|
@ -29,9 +29,6 @@ type (
|
|||
IsStarred bool `json:"starred,omitempty"`
|
||||
IsGated bool `json:"gated"`
|
||||
AllowPull bool `json:"allow_pr"`
|
||||
AllowPush bool `json:"allow_push"`
|
||||
AllowDeploy bool `json:"allow_deploys"`
|
||||
AllowTag bool `json:"allow_tags"`
|
||||
Config string `json:"config_file"`
|
||||
}
|
||||
|
||||
|
@ -43,9 +40,6 @@ type (
|
|||
Timeout *int64 `json:"timeout,omitempty"`
|
||||
Visibility *string `json:"visibility"`
|
||||
AllowPull *bool `json:"allow_pr,omitempty"`
|
||||
AllowPush *bool `json:"allow_push,omitempty"`
|
||||
AllowDeploy *bool `json:"allow_deploy,omitempty"`
|
||||
AllowTag *bool `json:"allow_tag,omitempty"`
|
||||
BuildCounter *int `json:"build_counter,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@ type Repo struct {
|
|||
IsGated bool `json:"gated" meddler:"repo_gated"`
|
||||
IsActive bool `json:"active" meddler:"repo_active"`
|
||||
AllowPull bool `json:"allow_pr" meddler:"repo_allow_pr"`
|
||||
AllowPush bool `json:"allow_push" meddler:"repo_allow_push"`
|
||||
AllowDeploy bool `json:"allow_deploys" meddler:"repo_allow_deploys"`
|
||||
AllowTag bool `json:"allow_tags" meddler:"repo_allow_tags"`
|
||||
Counter int `json:"last_build" meddler:"repo_counter"`
|
||||
Config string `json:"config_file" meddler:"repo_config_path"`
|
||||
Hash string `json:"-" meddler:"repo_hash"`
|
||||
|
@ -101,8 +98,5 @@ type RepoPatch struct {
|
|||
Timeout *int64 `json:"timeout,omitempty"`
|
||||
Visibility *string `json:"visibility,omitempty"`
|
||||
AllowPull *bool `json:"allow_pr,omitempty"`
|
||||
AllowPush *bool `json:"allow_push,omitempty"`
|
||||
AllowDeploy *bool `json:"allow_deploy,omitempty"`
|
||||
AllowTag *bool `json:"allow_tag,omitempty"`
|
||||
BuildCounter *int `json:"build_counter,omitempty"`
|
||||
}
|
||||
|
|
|
@ -134,16 +134,9 @@ func PostHook(c *gin.Context) {
|
|||
c.Writer.WriteHeader(204)
|
||||
return
|
||||
}
|
||||
var skipped = true
|
||||
if (build.Event == model.EventPush && repo.AllowPush) ||
|
||||
(build.Event == model.EventPull && repo.AllowPull) ||
|
||||
(build.Event == model.EventDeploy && repo.AllowDeploy) ||
|
||||
(build.Event == model.EventTag && repo.AllowTag) {
|
||||
skipped = false
|
||||
}
|
||||
|
||||
if skipped {
|
||||
logrus.Infof("ignoring hook. repo %s is disabled for %s events.", repo.FullName, build.Event)
|
||||
if build.Event == model.EventPull && !repo.AllowPull {
|
||||
logrus.Infof("ignoring hook. repo %s is disabled for pull requests.", repo.FullName)
|
||||
c.Writer.WriteHeader(204)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -42,19 +42,18 @@ func PostRepo(c *gin.Context) {
|
|||
|
||||
repo.IsActive = true
|
||||
repo.UserID = user.ID
|
||||
if !repo.AllowPush && !repo.AllowPull && !repo.AllowDeploy && !repo.AllowTag {
|
||||
repo.AllowPush = true
|
||||
repo.AllowPull = true
|
||||
}
|
||||
|
||||
if repo.Visibility == "" {
|
||||
repo.Visibility = model.VisibilityPublic
|
||||
if repo.IsPrivate {
|
||||
repo.Visibility = model.VisibilityPrivate
|
||||
}
|
||||
}
|
||||
|
||||
if repo.Timeout == 0 {
|
||||
repo.Timeout = 60 // 1 hour default build time
|
||||
}
|
||||
|
||||
if repo.Hash == "" {
|
||||
repo.Hash = base32.StdEncoding.EncodeToString(
|
||||
securecookie.GenerateRandomKey(32),
|
||||
|
@ -110,18 +109,9 @@ func PatchRepo(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if in.AllowPush != nil {
|
||||
repo.AllowPush = *in.AllowPush
|
||||
}
|
||||
if in.AllowPull != nil {
|
||||
repo.AllowPull = *in.AllowPull
|
||||
}
|
||||
if in.AllowDeploy != nil {
|
||||
repo.AllowDeploy = *in.AllowDeploy
|
||||
}
|
||||
if in.AllowTag != nil {
|
||||
repo.AllowTag = *in.AllowTag
|
||||
}
|
||||
if in.IsGated != nil {
|
||||
repo.IsGated = *in.IsGated
|
||||
}
|
||||
|
|
|
@ -93,10 +93,7 @@ paths:
|
|||
"timeout": 60,
|
||||
"private": false,
|
||||
"trusted": false,
|
||||
"allow_pr": true,
|
||||
"allow_push": true,
|
||||
"allow_deploys": false,
|
||||
"allow_tags": false
|
||||
"allow_pr": true
|
||||
}
|
||||
required: true
|
||||
tags:
|
||||
|
@ -655,10 +652,7 @@ definitions:
|
|||
"timeout": 60,
|
||||
"private": false,
|
||||
"trusted": false,
|
||||
"allow_pr": true,
|
||||
"allow_push": true,
|
||||
"allow_deploys": false,
|
||||
"allow_tags": false
|
||||
"allow_pr": true
|
||||
}
|
||||
properties:
|
||||
id:
|
||||
|
@ -712,15 +706,6 @@ definitions:
|
|||
allow_pr:
|
||||
description: Whether pull requests should trigger a build.
|
||||
type: boolean
|
||||
allow_push:
|
||||
description: Whether push events should trigger a build.
|
||||
type: boolean
|
||||
allow_deploys:
|
||||
description: Whether deployment events should trigger a build.
|
||||
type: boolean
|
||||
allow_tags:
|
||||
description: Whether tags should trigger a build.
|
||||
type: boolean
|
||||
|
||||
Build:
|
||||
description: A build for a repository.
|
||||
|
|
|
@ -204,6 +204,10 @@ var migrations = []struct {
|
|||
name: "alter-table-drop-repo-fallback",
|
||||
stmt: alterTableDropRepoFallback,
|
||||
},
|
||||
{
|
||||
name: "drop-allow-push-tags-deploys-columns",
|
||||
stmt: dropAllowPushTagsDeploysColumns,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -757,3 +761,11 @@ UPDATE builds SET changed_files='[]'
|
|||
var alterTableDropRepoFallback = `
|
||||
ALTER TABLE repos DROP COLUMN repo_fallback
|
||||
`
|
||||
|
||||
//
|
||||
// 027_drop_allow_push_tags_deployments_columns.sql
|
||||
//
|
||||
|
||||
var dropAllowPushTagsDeploysColumns = `
|
||||
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
|
||||
`
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
-- name: drop-allow-push-tags-deploys-columns
|
||||
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
|
|
@ -204,6 +204,10 @@ var migrations = []struct {
|
|||
name: "alter-table-drop-repo-fallback",
|
||||
stmt: alterTableDropRepoFallback,
|
||||
},
|
||||
{
|
||||
name: "drop-allow-push-tags-deploys-columns",
|
||||
stmt: dropAllowPushTagsDeploysColumns,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -759,3 +763,11 @@ UPDATE builds SET changed_files='[]'
|
|||
var alterTableDropRepoFallback = `
|
||||
ALTER TABLE repos DROP COLUMN repo_fallback
|
||||
`
|
||||
|
||||
//
|
||||
// 027_drop_allow_push_tags_deployments_columns.sql
|
||||
//
|
||||
|
||||
var dropAllowPushTagsDeploysColumns = `
|
||||
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
|
||||
`
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
-- name: drop-allow-push-tags-deploys-columns
|
||||
ALTER TABLE repos DROP COLUMN repo_allow_push, DROP COLUMN repo_allow_deploys, DROP COLUMN repo_allow_tags
|
|
@ -208,6 +208,10 @@ var migrations = []struct {
|
|||
name: "alter-table-drop-repo-fallback",
|
||||
stmt: alterTableDropRepoFallback,
|
||||
},
|
||||
{
|
||||
name: "drop-allow-push-tags-deploys-columns",
|
||||
stmt: dropAllowPushTagsDeploysColumns,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -812,3 +816,57 @@ DROP TABLE repos;
|
|||
ALTER TABLE repos_new RENAME TO repos;
|
||||
COMMIT;
|
||||
`
|
||||
|
||||
//
|
||||
// 027_drop_allow_push_tags_deployments_columns.sql
|
||||
//
|
||||
|
||||
var dropAllowPushTagsDeploysColumns = `
|
||||
BEGIN TRANSACTION;
|
||||
CREATE TABLE repos_new (
|
||||
repo_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
repo_user_id INTEGER,
|
||||
repo_owner TEXT,
|
||||
repo_name TEXT,
|
||||
repo_full_name TEXT,
|
||||
repo_avatar TEXT,
|
||||
repo_link TEXT,
|
||||
repo_clone TEXT,
|
||||
repo_branch TEXT,
|
||||
repo_timeout INTEGER,
|
||||
repo_private BOOLEAN,
|
||||
repo_trusted BOOLEAN,
|
||||
repo_active BOOLEAN,
|
||||
repo_allow_pr BOOLEAN,
|
||||
repo_hash TEXT,
|
||||
repo_scm TEXT,
|
||||
repo_config_path TEXT,
|
||||
repo_gated BOOLEAN,
|
||||
repo_visibility TEXT,
|
||||
repo_counter INTEGER,
|
||||
UNIQUE(repo_full_name)
|
||||
);
|
||||
INSERT INTO repos_new SELECT repo_id
|
||||
,repo_user_id
|
||||
,repo_owner
|
||||
,repo_name
|
||||
,repo_full_name
|
||||
,repo_avatar
|
||||
,repo_link
|
||||
,repo_clone
|
||||
,repo_branch
|
||||
,repo_timeout
|
||||
,repo_private
|
||||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter FROM repos;
|
||||
DROP TABLE repos;
|
||||
ALTER TABLE repos_new RENAME TO repos;
|
||||
COMMIT;
|
||||
`
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
-- name: drop-allow-push-tags-deploys-columns
|
||||
BEGIN TRANSACTION;
|
||||
CREATE TABLE repos_new (
|
||||
repo_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
repo_user_id INTEGER,
|
||||
repo_owner TEXT,
|
||||
repo_name TEXT,
|
||||
repo_full_name TEXT,
|
||||
repo_avatar TEXT,
|
||||
repo_link TEXT,
|
||||
repo_clone TEXT,
|
||||
repo_branch TEXT,
|
||||
repo_timeout INTEGER,
|
||||
repo_private BOOLEAN,
|
||||
repo_trusted BOOLEAN,
|
||||
repo_active BOOLEAN,
|
||||
repo_allow_pr BOOLEAN,
|
||||
repo_hash TEXT,
|
||||
repo_scm TEXT,
|
||||
repo_config_path TEXT,
|
||||
repo_gated BOOLEAN,
|
||||
repo_visibility TEXT,
|
||||
repo_counter INTEGER,
|
||||
UNIQUE(repo_full_name)
|
||||
);
|
||||
INSERT INTO repos_new SELECT repo_id
|
||||
,repo_user_id
|
||||
,repo_owner
|
||||
,repo_name
|
||||
,repo_full_name
|
||||
,repo_avatar
|
||||
,repo_link
|
||||
,repo_clone
|
||||
,repo_branch
|
||||
,repo_timeout
|
||||
,repo_private
|
||||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter FROM repos;
|
||||
DROP TABLE repos;
|
||||
ALTER TABLE repos_new RENAME TO repos;
|
||||
COMMIT;
|
|
@ -84,9 +84,6 @@ func (db *datastore) RepoBatch(repos []*model.Repo) error {
|
|||
repo.IsTrusted,
|
||||
repo.IsActive,
|
||||
repo.AllowPull,
|
||||
repo.AllowPush,
|
||||
repo.AllowDeploy,
|
||||
repo.AllowTag,
|
||||
repo.Hash,
|
||||
repo.Kind,
|
||||
repo.Config,
|
||||
|
|
|
@ -21,9 +21,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -51,16 +48,13 @@ INSERT IGNORE INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
|
||||
-- name: repo-delete
|
||||
|
||||
|
|
|
@ -439,9 +439,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -469,16 +466,13 @@ INSERT IGNORE INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
`
|
||||
|
||||
var repoDelete = `
|
||||
|
|
|
@ -21,9 +21,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -51,16 +48,13 @@ INSERT INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22)
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19)
|
||||
ON CONFLICT (repo_full_name) DO NOTHING
|
||||
|
||||
-- name: repo-delete
|
||||
|
|
|
@ -442,9 +442,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -472,16 +469,13 @@ INSERT INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22)
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19)
|
||||
ON CONFLICT (repo_full_name) DO NOTHING
|
||||
`
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -51,16 +48,13 @@ INSERT OR IGNORE INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
|
||||
-- name: repo-delete
|
||||
|
||||
|
|
|
@ -439,9 +439,6 @@ SELECT
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
|
@ -469,16 +466,13 @@ INSERT OR IGNORE INTO repos (
|
|||
,repo_trusted
|
||||
,repo_active
|
||||
,repo_allow_pr
|
||||
,repo_allow_push
|
||||
,repo_allow_deploys
|
||||
,repo_allow_tags
|
||||
,repo_hash
|
||||
,repo_scm
|
||||
,repo_config_path
|
||||
,repo_gated
|
||||
,repo_visibility
|
||||
,repo_counter
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
`
|
||||
|
||||
var repoDelete = `
|
||||
|
|
|
@ -32,10 +32,7 @@ export default class Settings extends Component {
|
|||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
this.handlePushChange = this.handlePushChange.bind(this);
|
||||
this.handlePullChange = this.handlePullChange.bind(this);
|
||||
this.handleTagChange = this.handleTagChange.bind(this);
|
||||
this.handleDeployChange = this.handleDeployChange.bind(this);
|
||||
this.handleTrustedChange = this.handleTrustedChange.bind(this);
|
||||
this.handleProtectedChange = this.handleProtectedChange.bind(this);
|
||||
this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
|
||||
|
@ -78,37 +75,13 @@ export default class Settings extends Component {
|
|||
<section>
|
||||
<h2>Repository Hooks</h2>
|
||||
<div>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={repo.allow_push}
|
||||
onChange={this.handlePushChange}
|
||||
/>
|
||||
<span>push</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={repo.allow_pr}
|
||||
onChange={this.handlePullChange}
|
||||
/>
|
||||
<span>pull request</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={repo.allow_tags}
|
||||
onChange={this.handleTagChange}
|
||||
/>
|
||||
<span>tag</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={repo.allow_deploys}
|
||||
onChange={this.handleDeployChange}
|
||||
/>
|
||||
<span>deployment</span>
|
||||
<span>Allow to execute pipelines on Pull-Requests</span>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -186,22 +159,10 @@ export default class Settings extends Component {
|
|||
);
|
||||
}
|
||||
|
||||
handlePushChange(e) {
|
||||
this.handleChange("allow_push", e.target.checked);
|
||||
}
|
||||
|
||||
handlePullChange(e) {
|
||||
this.handleChange("allow_pr", e.target.checked);
|
||||
}
|
||||
|
||||
handleTagChange(e) {
|
||||
this.handleChange("allow_tag", e.target.checked);
|
||||
}
|
||||
|
||||
handleDeployChange(e) {
|
||||
this.handleChange("allow_deploy", e.target.checked);
|
||||
}
|
||||
|
||||
handleTrustedChange(e) {
|
||||
this.handleChange("trusted", e.target.checked);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue