--- a/loaders/convey/convey.go Sun Jan 14 03:13:49 2018 -0600
+++ b/loaders/convey/convey.go Sun Jan 14 04:07:43 2018 -0600
@@ -63,6 +63,76 @@
fileLoader func(string, *Loader) (*cConfig.Config, error)
+func (l *Loader) loadBase(cfg config, path string, disableDeprecated bool) (*cConfig.Config, error) { + // see if we're extending something - partially load a base + // config object if so that we'll modify; otherwise use an + // empty base config object that we'll set in a similar way + if l.depth >= MaxExtendsDepth { + return nil, ErrMaxExtendsDepth + extendsAbsName := filepath.Join(path, cfg.Extends) + baseConfig, err := l.loadFile(extendsAbsName, disableDeprecated) + // We can safely ignore no plans and no tasks errors here + // as we're ensured to also get a valid base config back. + // This is a bit of a strange idiom, but is still used in + // places like io.Reader (return non-zero n on error). + if err != nil && err != ErrNoPlans && err != ErrNoTasks { + return &cConfig.Config{ + Tasks: map[string]tasks.Task{}, + Plans: map[string]plans.Plan{}, + MetaPlans: map[string]plans.MetaPlan{}, + SSHIdentities: []string{}, +func (l *Loader) loadPlans(baseConfig *cConfig.Config, cfg config) error { + // iterate through each plan and do any cleanup we need to + for _, plan := range cfg.Plans { + // set stage names for any that are missing them + for idx := range plan.Stages { + if plan.Stages[idx].Name == "" { + plan.Stages[idx].Name = fmt.Sprintf("stage-%d", idx) + // If the plan has the merge attribute set, try to overwrite + // stages of a plan that is already declared with the same name. + // If no such plan exists, raise an error (you're trying to + // overwrite a stage of nothing, which is almost certainly an error. + for name, plan := range cfg.Plans { + base, ok := baseConfig.Plans[name] + return fmt.Errorf("cannot merge with unknown plan '%s'", name) + base, err := mergePlan(base, plan, name) + baseConfig.Plans[name] = base + baseConfig.Plans[name] = plan // Load loads the given filename and returns it as a config.Config.
func (l *Loader) Load(path, base string, data []byte, disableDeprecated bool) (*cConfig.Config, error) {
@@ -76,37 +146,10 @@
- // see if we're extending something - partially load a base
- // config object if so that we'll modify; otherwise use an
- // empty base config object that we'll set in a similar way
- var baseConfig *cConfig.Config
- if l.depth >= MaxExtendsDepth {
- return nil, ErrMaxExtendsDepth
- extendsAbsName := filepath.Join(path, cfg.Extends)
- baseConfig, err = l.loadFile(extendsAbsName, disableDeprecated)
- // We can safely ignore no plans and no tasks errors here
- // as we're ensured to also get a valid base config back.
- // This is a bit of a strange idiom, but is still used in
- // places like io.Reader (return non-zero n on error).
- if err != nil && err != ErrNoPlans && err != ErrNoTasks {
- baseConfig = &cConfig.Config{
- Tasks: map[string]tasks.Task{},
- Plans: map[string]plans.Plan{},
- MetaPlans: map[string]plans.MetaPlan{},
- SSHIdentities: []string{},
+ baseConfig, err := l.loadBase(cfg, path, disableDeprecated) // turn the raw tasks into real tasks
@@ -115,14 +158,9 @@
- // iterate through each plan and do any cleanup we need to
- for _, plan := range cfg.Plans {
- // set stage names for any that are missing them
- for idx := range plan.Stages {
- if plan.Stages[idx].Name == "" {
- plan.Stages[idx].Name = fmt.Sprintf("stage-%d", idx)
+ err = l.loadPlans(baseConfig, cfg) // store the default plan in the loader
@@ -137,29 +175,6 @@
baseConfig.Tasks[name] = task
- // If the plan has the merge attribute set, try to overwrite
- // stages of a plan that is already declared with the same name.
- // If no such plan exists, raise an error (you're trying to
- // overwrite a stage of nothing, which is almost certainly an error.
- for name, plan := range cfg.Plans {
- base, ok := baseConfig.Plans[name]
- return nil, fmt.Errorf("cannot merge with unknown plan '%s'", name)
- base, err := mergePlan(base, plan, name)
- baseConfig.Plans[name] = base
- baseConfig.Plans[name] = plan
for name, metaPlan := range cfg.MetaPlans {
baseConfig.MetaPlans[name] = metaPlan