--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/extends-merge.yml Tue Oct 03 21:50:34 2017 -0500
@@ -0,0 +1,26 @@
+# This plan extends another plan by overwriting the pre and post +# stages of a plan defined in the parent config. This shows how +# to build "abstract" plans which can be extended in ways that +# allow blocks of plans to be replaced. + image: gliderlabs/alpine:edge + command: echo "<= before" + image: gliderlabs/alpine:edge + command: echo "=> after" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loaders/convey/plans.go Tue Oct 03 21:50:34 2017 -0500
@@ -0,0 +1,38 @@
+ "bitbucket.org/rw_grim/convey/environment" + "bitbucket.org/rw_grim/convey/plans" + "bitbucket.org/rw_grim/convey/stages" +// mergePlan modifies parent in-place so that any stage declared in child +// will overwrite the stage of the same name in parent. Return an error if +// a stage exists in child but not parent. Environments are also merged. +func mergePlan(parent, child plans.Plan, name string) (plans.Plan, error) { + for _, stage := range child.Stages { + if !replaceStage(parent, stage) { + return plans.Plan{}, fmt.Errorf( + "cannot overwrite stage '%s' in plan '%s' (no such stage in parent)", + parent.Environment = environment.Merge(parent.Environment, child.Environment) +func replaceStage(plan plans.Plan, stage stages.Stage) bool { + for i, match := range plan.Stages { + if match.Name == stage.Name {