Mercurial > grim > convey
changeset 308:b9db1550f3df
Add support for supporting multiple config file names. Fixes #81
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Thu, 27 Apr 2017 22:52:03 -0500 |
parents | 8a6ab07c1645 |
children | 2ba30683686f |
files | ChangeLog bitbucket/loader.go config/convey.go config/loader.go main.go |
diffstat | 5 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Apr 27 22:43:21 2017 -0500 +++ b/ChangeLog Thu Apr 27 22:52:03 2017 -0500 @@ -4,6 +4,7 @@ * Added support for metaplans (fixes #82) * Added support for making sure there are SSH identies available when using --ssh-agent. (Fixes #84) + * Added support for convey.yml and convey.yaml. (Fixes #81) * Updated the graphviz colors by removing the yellow colors and added a bunch more colors. (Fixes #77) * Fixed the graphviz output so that plans with graphviz reserved words no
--- a/bitbucket/loader.go Thu Apr 27 22:43:21 2017 -0500 +++ b/bitbucket/loader.go Thu Apr 27 22:52:03 2017 -0500 @@ -111,8 +111,8 @@ return } -func (l *Loader) Filename() string { - return "bitbucket-pipelines.yml" +func (l *Loader) Filenames() []string { + return []string{"bitbucket-pipelines.yml"} } func (l *Loader) OverrideSuffix() string {
--- a/config/convey.go Thu Apr 27 22:43:21 2017 -0500 +++ b/config/convey.go Thu Apr 27 22:52:03 2017 -0500 @@ -100,8 +100,8 @@ config.Environment = environment.Merge(config.Environment, overrideData.Environment) } -func (c *ConveyLoader) Filename() string { - return "convey.yml" +func (c *ConveyLoader) Filenames() []string { + return []string{"convey.yml", "convey.yaml"} } func (c *ConveyLoader) OverrideSuffix() string {
--- a/config/loader.go Thu Apr 27 22:43:21 2017 -0500 +++ b/config/loader.go Thu Apr 27 22:52:03 2017 -0500 @@ -30,7 +30,7 @@ type Loader interface { Load(path, base string, data []byte) (*Config, error) LoadOverride(path, base string, data []byte, config *Config) - Filename() string + Filenames() []string OverrideSuffix() string DefaultPlan() string ResolvePlanName(plan string, cfg *Config, opts *options.Options) string
--- a/main.go Thu Apr 27 22:43:21 2017 -0500 +++ b/main.go Thu Apr 27 22:52:03 2017 -0500 @@ -20,6 +20,7 @@ import ( "fmt" "os" + "strings" "github.com/alecthomas/kingpin" "github.com/aphistic/gomol" @@ -77,8 +78,22 @@ loader = &bitbucket.Loader{} } + // if a config file was not provided search for the loader's default file if *configFile == "" { - *configFile = loader.Filename() + for _, filename := range loader.Filenames() { + if _, err := os.Stat(filename); os.IsNotExist(err) { + continue + } + + *configFile = filename + break + } + } + + // now make sure we found a config file + if *configFile == "" { + fmt.Printf("config file not found, looking for %s\n", strings.Join(loader.Filenames(), ",")) + os.Exit(1) } cfg, err := config.LoadFile(*configFile, loader)