mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-09 17:15:31 +00:00
Fallback to default config. Allows incremental rollout of custom-path
This commit is contained in:
parent
be0d1d73fb
commit
8d79f8671e
11 changed files with 133 additions and 29 deletions
|
@ -55,6 +55,7 @@ type Repo struct {
|
||||||
Config string `json:"config_file" meddler:"repo_config_path"`
|
Config string `json:"config_file" meddler:"repo_config_path"`
|
||||||
Hash string `json:"-" meddler:"repo_hash"`
|
Hash string `json:"-" meddler:"repo_hash"`
|
||||||
Perm *Perm `json:"-" meddler:"-"`
|
Perm *Perm `json:"-" meddler:"-"`
|
||||||
|
Fallback bool `json:"fallback" meddler:"repo_fallback"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repo) ResetVisibility() {
|
func (r *Repo) ResetVisibility() {
|
||||||
|
@ -105,4 +106,5 @@ type RepoPatch struct {
|
||||||
AllowDeploy *bool `json:"allow_deploy,omitempty"`
|
AllowDeploy *bool `json:"allow_deploy,omitempty"`
|
||||||
AllowTag *bool `json:"allow_tag,omitempty"`
|
AllowTag *bool `json:"allow_tag,omitempty"`
|
||||||
BuildCounter *int `json:"build_counter,omitempty"`
|
BuildCounter *int `json:"build_counter,omitempty"`
|
||||||
|
Fallback *bool `json:"fallback,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,8 @@ func (cf *configFetcher) Fetch() ([]*remote.FileMeta, error) {
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Second * time.Duration(i)):
|
case <-time.After(time.Second * time.Duration(i)):
|
||||||
// .drone.yml takes precedence
|
|
||||||
file, fileerr := cf.remote_.File(cf.user, cf.repo, cf.build, ".drone.yml")
|
|
||||||
if fileerr == nil {
|
|
||||||
return []*remote.FileMeta{&remote.FileMeta{
|
|
||||||
Name: cf.repo.Config,
|
|
||||||
Data: file,
|
|
||||||
}}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// either a file
|
// either a file
|
||||||
file, fileerr = cf.remote_.File(cf.user, cf.repo, cf.build, cf.repo.Config)
|
file, fileerr := cf.remote_.File(cf.user, cf.repo, cf.build, cf.repo.Config)
|
||||||
if fileerr == nil {
|
if fileerr == nil {
|
||||||
return []*remote.FileMeta{&remote.FileMeta{
|
return []*remote.FileMeta{&remote.FileMeta{
|
||||||
Name: cf.repo.Config,
|
Name: cf.repo.Config,
|
||||||
|
@ -39,11 +30,23 @@ func (cf *configFetcher) Fetch() ([]*remote.FileMeta, error) {
|
||||||
|
|
||||||
// or a folder
|
// or a folder
|
||||||
dir, direrr := cf.remote_.Dir(cf.user, cf.repo, cf.build, strings.TrimSuffix(cf.repo.Config, "/"))
|
dir, direrr := cf.remote_.Dir(cf.user, cf.repo, cf.build, strings.TrimSuffix(cf.repo.Config, "/"))
|
||||||
if direrr != nil {
|
|
||||||
|
if direrr == nil {
|
||||||
|
return dir, nil
|
||||||
|
} else if !cf.repo.Fallback {
|
||||||
return nil, direrr
|
return nil, direrr
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir, nil
|
// or fallback
|
||||||
|
file, fileerr = cf.remote_.File(cf.user, cf.repo, cf.build, ".drone.yml")
|
||||||
|
if fileerr != nil {
|
||||||
|
return nil, fileerr
|
||||||
|
}
|
||||||
|
|
||||||
|
return []*remote.FileMeta{&remote.FileMeta{
|
||||||
|
Name: cf.repo.Config,
|
||||||
|
Data: file,
|
||||||
|
}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []*remote.FileMeta{}, nil
|
return []*remote.FileMeta{}, nil
|
||||||
|
|
|
@ -150,6 +150,9 @@ func PatchRepo(c *gin.Context) {
|
||||||
if in.BuildCounter != nil {
|
if in.BuildCounter != nil {
|
||||||
repo.Counter = *in.BuildCounter
|
repo.Counter = *in.BuildCounter
|
||||||
}
|
}
|
||||||
|
if in.Fallback != nil {
|
||||||
|
repo.Fallback = *in.Fallback
|
||||||
|
}
|
||||||
|
|
||||||
err := store.UpdateRepo(c, repo)
|
err := store.UpdateRepo(c, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -180,6 +180,14 @@ var migrations = []struct {
|
||||||
name: "alter-table-add-task-run-on",
|
name: "alter-table-add-task-run-on",
|
||||||
stmt: alterTableAddTaskRunOn,
|
stmt: alterTableAddTaskRunOn,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "alter-table-add-repo-fallback",
|
||||||
|
stmt: alterTableAddRepoFallback,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "update-table-set-repo-fallback",
|
||||||
|
stmt: updateTableSetRepoFallback,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate performs the database migration. If the migration fails
|
// Migrate performs the database migration. If the migration fails
|
||||||
|
@ -693,3 +701,15 @@ ALTER TABLE tasks ADD COLUMN task_dependencies MEDIUMBLOB
|
||||||
var alterTableAddTaskRunOn = `
|
var alterTableAddTaskRunOn = `
|
||||||
ALTER TABLE tasks ADD COLUMN task_run_on MEDIUMBLOB
|
ALTER TABLE tasks ADD COLUMN task_run_on MEDIUMBLOB
|
||||||
`
|
`
|
||||||
|
|
||||||
|
//
|
||||||
|
// 023_add_repo_fallback_column.sql
|
||||||
|
//
|
||||||
|
|
||||||
|
var alterTableAddRepoFallback = `
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
`
|
||||||
|
|
||||||
|
var updateTableSetRepoFallback = `
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
||||||
|
`
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- name: alter-table-add-repo-fallback
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
|
||||||
|
-- name: update-table-set-repo-fallback
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
|
@ -180,6 +180,14 @@ var migrations = []struct {
|
||||||
name: "alter-table-add-task-run-on",
|
name: "alter-table-add-task-run-on",
|
||||||
stmt: alterTableAddTaskRunOn,
|
stmt: alterTableAddTaskRunOn,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "alter-table-add-repo-fallback",
|
||||||
|
stmt: alterTableAddRepoFallback,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "update-table-set-repo-fallback",
|
||||||
|
stmt: updateTableSetRepoFallback,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate performs the database migration. If the migration fails
|
// Migrate performs the database migration. If the migration fails
|
||||||
|
@ -695,3 +703,15 @@ ALTER TABLE tasks ADD COLUMN task_dependencies BYTEA
|
||||||
var alterTableAddTaskRunOn = `
|
var alterTableAddTaskRunOn = `
|
||||||
ALTER TABLE tasks ADD COLUMN task_run_on BYTEA
|
ALTER TABLE tasks ADD COLUMN task_run_on BYTEA
|
||||||
`
|
`
|
||||||
|
|
||||||
|
//
|
||||||
|
// 023_add_repo_fallback_column.sql
|
||||||
|
//
|
||||||
|
|
||||||
|
var alterTableAddRepoFallback = `
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
`
|
||||||
|
|
||||||
|
var updateTableSetRepoFallback = `
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
||||||
|
`
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- name: alter-table-add-repo-fallback
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
|
||||||
|
-- name: update-table-set-repo-fallback
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
|
@ -184,6 +184,14 @@ var migrations = []struct {
|
||||||
name: "alter-table-add-task-run-on",
|
name: "alter-table-add-task-run-on",
|
||||||
stmt: alterTableAddTaskRunOn,
|
stmt: alterTableAddTaskRunOn,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "alter-table-add-repo-fallback",
|
||||||
|
stmt: alterTableAddRepoFallback,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "update-table-set-repo-fallback",
|
||||||
|
stmt: updateTableSetRepoFallback,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate performs the database migration. If the migration fails
|
// Migrate performs the database migration. If the migration fails
|
||||||
|
@ -694,3 +702,15 @@ ALTER TABLE tasks ADD COLUMN task_dependencies BLOB
|
||||||
var alterTableAddTaskRunOn = `
|
var alterTableAddTaskRunOn = `
|
||||||
ALTER TABLE tasks ADD COLUMN task_run_on BLOB
|
ALTER TABLE tasks ADD COLUMN task_run_on BLOB
|
||||||
`
|
`
|
||||||
|
|
||||||
|
//
|
||||||
|
// 023_add_repo_fallback_column.sql
|
||||||
|
//
|
||||||
|
|
||||||
|
var alterTableAddRepoFallback = `
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
`
|
||||||
|
|
||||||
|
var updateTableSetRepoFallback = `
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
||||||
|
`
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- name: alter-table-add-repo-fallback
|
||||||
|
ALTER TABLE repos ADD COLUMN repo_fallback BOOLEAN
|
||||||
|
|
||||||
|
-- name: update-table-set-repo-fallback
|
||||||
|
UPDATE repos SET repo_fallback='false'
|
47
vendor/github.com/laszlocph/drone-ui/dist/dist_gen.go
generated
vendored
47
vendor/github.com/laszlocph/drone-ui/dist/dist_gen.go
generated
vendored
File diff suppressed because one or more lines are too long
8
vendor/vendor.json
vendored
8
vendor/vendor.json
vendored
|
@ -425,10 +425,12 @@
|
||||||
"revisionTime": "2016-05-04T02:26:26Z"
|
"revisionTime": "2016-05-04T02:26:26Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "i3dVVpc0/It5nJIt/LEOHNuvqQY=",
|
"checksumSHA1": "R/gRUF6hXEFbDGSIOKt6VdCPwHE=",
|
||||||
"path": "github.com/laszlocph/drone-ui/dist",
|
"path": "github.com/laszlocph/drone-ui/dist",
|
||||||
"revision": "106788432c8e9f19ee7a73fd977ef15d32cca79d",
|
"revision": "1c55c6bab89440efc658a708ba7bb3424dbd5d0d",
|
||||||
"revisionTime": "2019-06-24T07:03:37Z"
|
"revisionTime": "2019-06-25T11:41:53Z",
|
||||||
|
"version": "fallback-config",
|
||||||
|
"versionExact": "fallback-config"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/lib/pq",
|
"path": "github.com/lib/pq",
|
||||||
|
|
Loading…
Reference in a new issue