--- a/ChangeLog Sun Jan 07 04:25:00 2018 -0600
+++ b/ChangeLog Sun Jan 07 22:06:42 2018 -0600
@@ -1,5 +1,13 @@
- * Nothing yet! Be the first!!
+ * Changed the way subcommands are run. Fixed #153 + * Added `run` sub-command. + * Deprecated `--graphviz`, use `graphviz` instead. + * Deprecated `--list-environment`, use `list environment` instead. + * Deprecated `--list-plans`, use `list plans` instead. + * Deprecated `--list-meta-plans`, use `list metaplans` instead. + * Deprecated `--list-tasks`, use `list tasks` instead. + * Deprecated `--show-config`, use `config` instead. + * Renamed `--allow-deprecated` to `--disable-deprecated`. * Deprecated engine attribute, and changed type attribute to be {engine}/{type}. Warnings will be output if legacy formats are detected. Fixed # 143
--- a/config/loader.go Sun Jan 07 04:25:00 2018 -0600
+++ b/config/loader.go Sun Jan 07 22:06:42 2018 -0600
@@ -28,8 +28,8 @@
- Load(path, base string, data []byte, allowDeprecated bool) (*Config, error)
- LoadOverride(path, base string, data []byte, config *Config, allowDeprecated bool)
+ Load(path, base string, data []byte, disableDeprecated bool) (*Config, error) + LoadOverride(path, base string, data []byte, config *Config, disableDeprecated bool) @@ -43,7 +43,7 @@
return base + loader.OverrideSuffix() + ext
-func loadOverride(path, base string, loader Loader, cfg *Config, allowDeprecated bool) {
+func loadOverride(path, base string, loader Loader, cfg *Config, disableDeprecated bool) { overrideFilename := determineFilename(base, loader)
absName := filepath.Join(path, overrideFilename)
@@ -58,10 +58,10 @@
- loader.LoadOverride(path, base, data, cfg, allowDeprecated)
+ loader.LoadOverride(path, base, data, cfg, disableDeprecated) -func LoadFile(file string, loader Loader, allowDeprecated bool) (*Config, error) {
+func LoadFile(file string, loader Loader, disableDeprecated bool) (*Config, error) { // split the filename into our parts
path, base := filepath.Split(file)
@@ -70,12 +70,12 @@
return nil, fmt.Errorf("failed to read config file '%s'", file)
- cfg, err := loader.Load(path, base, data, allowDeprecated)
+ cfg, err := loader.Load(path, base, data, disableDeprecated) - loadOverride(path, base, loader, cfg, allowDeprecated)
+ loadOverride(path, base, loader, cfg, disableDeprecated) --- a/config/override_test.go Sun Jan 07 04:25:00 2018 -0600
+++ b/config/override_test.go Sun Jan 07 22:06:42 2018 -0600
@@ -26,11 +26,11 @@
-func (l *testLoader) Load(path, base string, data []byte, allowDeprecated bool) (*Config, error) {
+func (l *testLoader) Load(path, base string, data []byte, disableDeprecated bool) (*Config, error) { -func (l *testLoader) LoadOverride(path, base string, data []byte, cfg *Config, allowDeprecated bool) {
+func (l *testLoader) LoadOverride(path, base string, data []byte, cfg *Config, disableDeprecated bool) { func (l *testLoader) OverrideSuffix() string {
--- a/loaders/bitbucket/loader.go Sun Jan 07 04:25:00 2018 -0600
+++ b/loaders/bitbucket/loader.go Sun Jan 07 22:06:42 2018 -0600
@@ -172,7 +172,7 @@
-func (l *Loader) Load(base, path string, data []byte, allowDeprecated bool) (*config.Config, error) {
+func (l *Loader) Load(base, path string, data []byte, disableDeprecated bool) (*config.Config, error) { var pipeline bitbucketPipelines
err := yaml.Unmarshal(data, &pipeline)
@@ -236,7 +236,7 @@
-func (l *Loader) LoadOverride(base, path string, data []byte, cfg *config.Config, allowDeprecated bool) {
+func (l *Loader) LoadOverride(base, path string, data []byte, cfg *config.Config, disableDeprecated bool) { --- a/loaders/convey/convey.go Sun Jan 07 04:25:00 2018 -0600
+++ b/loaders/convey/convey.go Sun Jan 07 22:06:42 2018 -0600
@@ -62,7 +62,7 @@
fileLoader func(string, *Loader) (*cConfig.Config, error)
-func (c *Loader) Load(path, base string, data []byte, allowDeprecated bool) (*cConfig.Config, error) {
+func (c *Loader) Load(path, base string, data []byte, disableDeprecated bool) (*cConfig.Config, error) { c.logger = logging.NewAdapter("config loader")
@@ -88,7 +88,7 @@
extendsAbsName := filepath.Join(path, cfg.Extends)
- baseConfig, err = c.loadFile(extendsAbsName, allowDeprecated)
+ baseConfig, err = c.loadFile(extendsAbsName, disableDeprecated) // We can safely ignore no plans and no tasks errors here
@@ -108,7 +108,7 @@
// turn the raw tasks into real tasks
- realTasks, err := loadTasks(path, cfg.Tasks, c.logger)
+ realTasks, err := loadTasks(path, cfg.Tasks, c.logger, disableDeprecated) @@ -271,15 +271,15 @@
-func (c *Loader) loadFile(path string, allowDeprecated bool) (*cConfig.Config, error) {
+func (c *Loader) loadFile(path string, disableDeprecated bool) (*cConfig.Config, error) { - return cConfig.LoadFile(path, c, allowDeprecated)
+ return cConfig.LoadFile(path, c, disableDeprecated) return c.fileLoader(path, c)
-func (c *Loader) LoadOverride(path, base string, data []byte, config *cConfig.Config, allowDeprecated bool) {
+func (c *Loader) LoadOverride(path, base string, data []byte, config *cConfig.Config, disableDeprecated bool) { var overrideData override
err := yaml.Unmarshal(data, &overrideData)
--- a/loaders/convey/tasks.go Sun Jan 07 04:25:00 2018 -0600
+++ b/loaders/convey/tasks.go Sun Jan 07 22:06:42 2018 -0600
@@ -58,7 +58,7 @@
-func loadTask(name string, yamlTask yaml.MapSlice, logger *gomol.LogAdapter) (tasks.Task, error) {
+func loadTask(name string, yamlTask yaml.MapSlice, logger *gomol.LogAdapter, disableDeprecated bool) (tasks.Task, error) { // figure out the engine and type for the task
@@ -78,8 +78,14 @@
task, ok := cConfig.TasksMap[rawType]
- // if the task is in the new format, we're done
+ // if the task isn't in the new format try to lookup the old format + // TODO remove when the old format for task types is removed. + // if deprecated tasks are disabled, just bomb out + return nil, fmt.Errorf("task '%s' not found", rawType) rawTask, err := loadLegacyTask(rawEngine, rawType, logger)
@@ -101,11 +107,11 @@
-func loadTasks(path string, raw map[string]yaml.MapSlice, logger *gomol.LogAdapter) (map[string]tasks.Task, error) {
+func loadTasks(path string, raw map[string]yaml.MapSlice, logger *gomol.LogAdapter, disableDeprecated bool) (map[string]tasks.Task, error) { realTasks := map[string]tasks.Task{}
for name, task := range raw {
- realTask, err := loadTask(name, task, logger)
+ realTask, err := loadTask(name, task, logger, disableDeprecated) --- a/main.go Sun Jan 07 04:25:00 2018 -0600
+++ b/main.go Sun Jan 07 22:06:42 2018 -0600
@@ -45,34 +45,45 @@
app = kingpin.New("convey", "container runner").Version(version)
- color = app.Flag("color", "Enable colorized output").Default("true").Bool()
- configLoader = app.Flag("config-loader", "Select the configuration loader").Short('l').Default("convey").Enum("convey", "bitbucket")
- configFile = app.Flag("config", "The config file name to use").Short('f').String()
- cpuShares = app.Flag("cpu-shares", "The amount of cpu shares to give to a run task").Short('c').String()
- dockerConfig = app.Flag("docker-config", "Location of docker client config files").String()
- env = app.Flag("env", "Set environment variables").Short('e').Strings()
- forceSequential = app.Flag("force-sequential", "Don't run anything concurrently").Short('S').Default("False").Bool()
- graphviz = app.Flag("graphviz", "Output a graphviz diagram of the config file").Short('g').Default("False").Bool()
- keep = app.Flag("keep", "Keep the workspace volume").Short('k').Hidden().Default("False").Bool()
- listEnvironment = app.Flag("list-environment", "List the environment variables that are available").Short('E').Default("false").Bool()
- listMetaPlans = app.Flag("list-meta-plans", "List the meta plans that are available").Short('M').Default("false").Bool()
- listPlans = app.Flag("list-plans", "List the plans that are available").Short('P').Default("false").Bool()
- listTasks = app.Flag("list-tasks", "List the supported tasks").Short('L').Default("false").Bool()
- memory = app.Flag("memory", "The amount of memory to give the run task").Short('m').String()
- showConfig = app.Flag("show-config", "Show a dump of the config file").Short('C').Hidden().Default("false").Bool()
- sshAgent = app.Flag("ssh-agent", "A shortcut for --ssh-identity=*").Default("false").Bool()
- sshIdentities = app.Flag("ssh-identity", "Enable ssh-agent for the given identities").Strings()
- planTimeout = app.Flag("timeout", "The maximum amount of time a plan can run. 0 to disable. Units must be specified.").Default("15m").Duration()
- verbose = app.Flag("verbose", "Be more verbose").Short('v').Default("False").Bool()
- allowDeprecated = app.Flag("allow-deprecated", "Allow the user of deprecated features").Default("False").Bool()
+ color = app.Flag("color", "Enable colorized output").Default("true").Bool() + configLoader = app.Flag("config-loader", "Select the configuration loader").Short('l').Default("convey").Enum("convey", "bitbucket") + configFile = app.Flag("config", "The config file name to use").Short('f').String() + cpuShares = app.Flag("cpu-shares", "The amount of cpu shares to give to a run task").Short('c').String() + dockerConfig = app.Flag("docker-config", "Location of docker client config files").String() + env = app.Flag("env", "Set environment variables").Short('e').Strings() + forceSequential = app.Flag("force-sequential", "Don't run anything concurrently").Short('S').Default("False").Bool() + graphviz = app.Flag("graphviz", "Output a graphviz diagram of the config file").Short('g').Hidden().Default("False").Bool() + keep = app.Flag("keep", "Keep the workspace volume").Short('k').Hidden().Default("False").Bool() + listEnvironment = app.Flag("list-environment", "List the environment variables that are available").Short('E').Hidden().Default("false").Bool() + listMetaPlans = app.Flag("list-meta-plans", "List the meta plans that are available").Short('M').Hidden().Default("false").Bool() + listPlans = app.Flag("list-plans", "List the plans that are available").Short('P').Hidden().Default("false").Bool() + listTasks = app.Flag("list-tasks", "List the supported tasks").Short('L').Hidden().Default("false").Bool() + memory = app.Flag("memory", "The amount of memory to give the run task").Short('m').String() + showConfig = app.Flag("show-config", "Show a dump of the config file").Short('C').Hidden().Default("false").Bool() + sshAgent = app.Flag("ssh-agent", "A shortcut for --ssh-identity=*").Default("false").Bool() + sshIdentities = app.Flag("ssh-identity", "Enable ssh-agent for the given identities").Strings() + planTimeout = app.Flag("timeout", "The maximum amount of time a plan can run. 0 to disable. Units must be specified.").Default("15m").Duration() + verbose = app.Flag("verbose", "Be more verbose").Short('v').Default("False").Bool() + disableDeprecated = app.Flag("disable-deprecated", "Allow the user of deprecated features").Default("False").Bool() - planNames = app.Arg("plan", "The plan or list of plans to run in specified order").Default("default").Strings()
+ _ = app.Command("config", "Show a dump of the config file") + _ = app.Command("environment", "List the environment variables that are available") + _ = app.Command("graphviz", "Output a graphviz diagram of the config file") + run = app.Command("run", "Run a plan or metaplan").Default() + planNames = run.Arg("plan", "The plan or list of plans to run in specified order").Default("default").Strings() + ls = app.Command("list", "List information").Alias("ls") + _ = ls.Command("environment", "List environment").Alias("env") + _ = ls.Command("metaplans", "List metaplans") + _ = ls.Command("plans", "List plans") + _ = ls.Command("tasks", "List tasks") - _, err := app.Parse(args)
+ command, err := app.Parse(args) @@ -119,7 +130,7 @@
- cfg, err := config.LoadFile(*configFile, loader, *allowDeprecated)
+ cfg, err := config.LoadFile(*configFile, loader, *disableDeprecated) @@ -154,7 +165,7 @@
st.CleanupList = cleanupList
- st.AllowDeprecated = *allowDeprecated
+ st.DisableDeprecated = *disableDeprecated st.ForceSequential = *forceSequential
st.EnableSSHAgent = enableSSHAgent
st.PlanTimeout = *planTimeout
@@ -169,20 +180,53 @@
+ if *disableDeprecated { + fmt.Printf("--graphviz is deprecated, use 'convey graphviz` instead") + } else if *listEnvironment { + if *disableDeprecated { + fmt.Printf("--list-environment is deprecated, use 'convey list environment` instead") + command = "list environment" + } else if *listMetaPlans { + if *disableDeprecated { + fmt.Printf("--list-metaplans is deprecated, use `convey list metaplans` instead") + command = "list metaplans" + if *disableDeprecated { + fmt.Printf("--list-plans is deprecated, use `convey list plans` instead") + if *disableDeprecated { + fmt.Printf("--list-tasks is deprecated, use `convey list tasks` instead") + } else if *showConfig { + if *disableDeprecated { + fmt.Printf("--list-plans is deprecated, use `convey config` instead") var runner runners.Runner
runner = &runners.Graphviz{}
- } else if *listEnvironment {
+ case "list environment": runner = &runners.ListEnvironment{}
- } else if *listMetaPlans {
runner = &runners.ListMetaPlans{}
runner = &runners.ListPlans{}
runner = &runners.ListTasks{}
- } else if *showConfig {
runner = &runners.ShowConfig{}
runner = &runners.Default{}
--- a/state/state.go Sun Jan 07 04:25:00 2018 -0600
+++ b/state/state.go Sun Jan 07 22:06:42 2018 -0600
@@ -39,10 +39,10 @@
Workspace workspace.Workspace
- PlanTimeout time.Duration
+ PlanTimeout time.Duration