mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Merge pull request #1972 from bradrydzewski/master
ability to customize yaml path
This commit is contained in:
commit
c0940dec25
9 changed files with 9 additions and 15 deletions
|
@ -3,8 +3,6 @@ package model
|
||||||
// Config defines system configuration parameters.
|
// Config defines system configuration parameters.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Open bool // Enables open registration
|
Open bool // Enables open registration
|
||||||
Yaml string // Customize the Yaml configuration file name
|
|
||||||
Shasum string // Customize the Yaml checksum file name
|
|
||||||
Secret string // Secret token used to authenticate agents
|
Secret string // Secret token used to authenticate agents
|
||||||
Admins map[string]bool // Administrative users
|
Admins map[string]bool // Administrative users
|
||||||
Orgs map[string]bool // Organization whitelist
|
Orgs map[string]bool // Organization whitelist
|
||||||
|
|
|
@ -29,6 +29,6 @@ type Repo struct {
|
||||||
AllowPush bool `json:"allow_push" meddler:"repo_allow_push"`
|
AllowPush bool `json:"allow_push" meddler:"repo_allow_push"`
|
||||||
AllowDeploy bool `json:"allow_deploys" meddler:"repo_allow_deploys"`
|
AllowDeploy bool `json:"allow_deploys" meddler:"repo_allow_deploys"`
|
||||||
AllowTag bool `json:"allow_tags" meddler:"repo_allow_tags"`
|
AllowTag bool `json:"allow_tags" meddler:"repo_allow_tags"`
|
||||||
Config string `json:"config_path" 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"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ func Config(cli *cli.Context) gin.HandlerFunc {
|
||||||
func setupConfig(c *cli.Context) *model.Config {
|
func setupConfig(c *cli.Context) *model.Config {
|
||||||
return &model.Config{
|
return &model.Config{
|
||||||
Open: c.Bool("open"),
|
Open: c.Bool("open"),
|
||||||
Yaml: c.String("yaml"),
|
|
||||||
Shasum: c.String("yaml") + ".sig",
|
|
||||||
Secret: c.String("agent-secret"),
|
Secret: c.String("agent-secret"),
|
||||||
Admins: sliceToMap(c.StringSlice("admin")),
|
Admins: sliceToMap(c.StringSlice("admin")),
|
||||||
Orgs: sliceToMap(c.StringSlice("orgs")),
|
Orgs: sliceToMap(c.StringSlice("orgs")),
|
||||||
|
|
|
@ -188,8 +188,7 @@ func PostApproval(c *gin.Context) {
|
||||||
//
|
//
|
||||||
|
|
||||||
// fetch the build file from the database
|
// fetch the build file from the database
|
||||||
cfg := ToConfig(c)
|
raw, err := remote_.File(user, repo, build, repo.Config)
|
||||||
raw, err := remote_.File(user, repo, build, cfg.Yaml)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
||||||
c.AbortWithError(404, err)
|
c.AbortWithError(404, err)
|
||||||
|
@ -398,8 +397,7 @@ func PostBuild(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch the .drone.yml file from the database
|
// fetch the .drone.yml file from the database
|
||||||
cfg := ToConfig(c)
|
raw, err := remote_.File(user, repo, build, repo.Config)
|
||||||
raw, err := remote_.File(user, repo, build, cfg.Yaml)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
||||||
c.AbortWithError(404, err)
|
c.AbortWithError(404, err)
|
||||||
|
|
|
@ -132,8 +132,7 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch the build file from the database
|
// fetch the build file from the database
|
||||||
cfg := ToConfig(c)
|
raw, err := remote_.File(user, repo, build, repo.Config)
|
||||||
raw, err := remote_.File(user, repo, build, cfg.Yaml)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err)
|
||||||
c.AbortWithError(404, err)
|
c.AbortWithError(404, err)
|
||||||
|
@ -177,7 +176,7 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if build.Event == model.EventPull && mustApprove {
|
if build.Event == model.EventPull && mustApprove {
|
||||||
old, ferr := remote_.FileRef(user, repo, build.Branch, cfg.Yaml)
|
old, ferr := remote_.FileRef(user, repo, build.Branch, repo.Config)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
build.Status = model.StatusBlocked
|
build.Status = model.StatusBlocked
|
||||||
logrus.Debugf("cannot fetch base yaml: status: blocked")
|
logrus.Debugf("cannot fetch base yaml: status: blocked")
|
||||||
|
|
|
@ -54,6 +54,7 @@ func PostRepo(c *gin.Context) {
|
||||||
r.UserID = user.ID
|
r.UserID = user.ID
|
||||||
r.AllowPush = true
|
r.AllowPush = true
|
||||||
r.AllowPull = true
|
r.AllowPull = true
|
||||||
|
r.Config = ".drone.yml"
|
||||||
r.Timeout = 60 // 1 hour default build time
|
r.Timeout = 60 // 1 hour default build time
|
||||||
r.Hash = base32.StdEncoding.EncodeToString(
|
r.Hash = base32.StdEncoding.EncodeToString(
|
||||||
securecookie.GenerateRandomKey(32),
|
securecookie.GenerateRandomKey(32),
|
||||||
|
|
|
@ -5,7 +5,7 @@ ALTER TABLE builds ADD COLUMN build_sender VARCHAR(255);
|
||||||
ALTER TABLE builds ADD COLUMN build_reviewer VARCHAR(255);
|
ALTER TABLE builds ADD COLUMN build_reviewer VARCHAR(255);
|
||||||
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
||||||
|
|
||||||
UPDATE repos SET repo_config_path = '';
|
UPDATE repos SET repo_config_path = '.drone.yml';
|
||||||
UPDATE builds SET build_reviewer = '';
|
UPDATE builds SET build_reviewer = '';
|
||||||
UPDATE builds SET build_reviewed = 0;
|
UPDATE builds SET build_reviewed = 0;
|
||||||
UPDATE builds SET build_sender = '';
|
UPDATE builds SET build_sender = '';
|
||||||
|
|
|
@ -5,7 +5,7 @@ ALTER TABLE builds ADD COLUMN build_reviewer VARCHAR(255);
|
||||||
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
||||||
ALTER TABLE builds ADD COLUMN build_sender VARCHAR(255);
|
ALTER TABLE builds ADD COLUMN build_sender VARCHAR(255);
|
||||||
|
|
||||||
UPDATE repos SET repo_config_path = '';
|
UPDATE repos SET repo_config_path = '.drone.yml';
|
||||||
UPDATE builds SET build_reviewer = '';
|
UPDATE builds SET build_reviewer = '';
|
||||||
UPDATE builds SET build_reviewed = 0;
|
UPDATE builds SET build_reviewed = 0;
|
||||||
UPDATE builds SET build_sender = '';
|
UPDATE builds SET build_sender = '';
|
||||||
|
|
|
@ -5,7 +5,7 @@ ALTER TABLE builds ADD COLUMN build_reviewer TEXT;
|
||||||
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
ALTER TABLE builds ADD COLUMN build_reviewed INTEGER;
|
||||||
ALTER TABLE builds ADD COLUMN build_sender TEXT;
|
ALTER TABLE builds ADD COLUMN build_sender TEXT;
|
||||||
|
|
||||||
UPDATE repos SET repo_config_path = '';
|
UPDATE repos SET repo_config_path = '.drone.yml';
|
||||||
UPDATE builds SET build_reviewer = '';
|
UPDATE builds SET build_reviewer = '';
|
||||||
UPDATE builds SET build_reviewed = 0;
|
UPDATE builds SET build_reviewed = 0;
|
||||||
UPDATE builds SET build_sender = '';
|
UPDATE builds SET build_sender = '';
|
||||||
|
|
Loading…
Reference in a new issue