Add server env var to specify .drone.yml location

Allow setting DRONE_REPO_CONFIG to override default location of .drone.yml
This commit is contained in:
Matt Leung 2017-09-12 16:57:25 -07:00
parent 538f256834
commit 820d07263b
3 changed files with 9 additions and 1 deletions

View file

@ -93,6 +93,12 @@ var flags = []cli.Flag{
Name: "open",
Usage: "open user registration",
},
cli.StringFlag{
EnvVar: "DRONE_REPO_CONFIG",
Name: "repo-config",
Usage: "file path for the drone config",
Value: ".drone.yml",
},
cli.DurationFlag{
EnvVar: "DRONE_SESSION_EXPIRES",
Name: "session-expires",
@ -639,6 +645,7 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
droneserver.Config.Server.Pass = c.String("agent-secret")
droneserver.Config.Server.Host = strings.TrimRight(c.String("server-host"), "/")
droneserver.Config.Server.Port = c.String("server-addr")
droneserver.Config.Server.RepoConfig = c.String("repo-config")
droneserver.Config.Server.SessionExpires = c.Duration("session-expires")
droneserver.Config.Pipeline.Networks = c.StringSlice("network")
droneserver.Config.Pipeline.Volumes = c.StringSlice("volume")

View file

@ -45,7 +45,7 @@ func PostRepo(c *gin.Context) {
}
}
if repo.Config == "" {
repo.Config = ".drone.yml"
repo.Config = Config.Server.RepoConfig
}
if repo.Timeout == 0 {
repo.Timeout = 60 // 1 hour default build time

View file

@ -60,6 +60,7 @@ var Config = struct {
Host string
Port string
Pass string
RepoConfig string
SessionExpires time.Duration
// Open bool
// Orgs map[string]struct{}