summaryrefslogtreecommitdiff
path: root/actions/recipe_action.go
diff options
context:
space:
mode:
Diffstat (limited to 'actions/recipe_action.go')
-rw-r--r--actions/recipe_action.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/actions/recipe_action.go b/actions/recipe_action.go
index e48f650..d9500dd 100644
--- a/actions/recipe_action.go
+++ b/actions/recipe_action.go
@@ -35,6 +35,7 @@ type RecipeAction struct {
Variables map[string]string
Actions Recipe `yaml:"-"`
templateVars map[string]string
+ context debos.DebosContext
}
func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
@@ -42,10 +43,13 @@ func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
return errors.New("'recipe' property can't be empty")
}
+ recipe.context = *context
+
file := recipe.Recipe
if !filepath.IsAbs(file) {
file = filepath.Clean(context.RecipeDir + "/" + recipe.Recipe)
}
+ recipe.context.RecipeDir = filepath.Dir(file)
if _, err := os.Stat(file); os.IsNotExist(err) {
return err
@@ -53,7 +57,6 @@ func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
// Initialise template vars
recipe.templateVars = make(map[string]string)
- recipe.templateVars["included_recipe"] = "true"
recipe.templateVars["architecture"] = context.Architecture
// Add Variables to template vars
@@ -65,12 +68,12 @@ func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
return err
}
- if context.Architecture != recipe.Actions.Architecture {
+ if recipe.context.Architecture != recipe.Actions.Architecture {
return fmt.Errorf("Expect architecture '%s' but got '%s'", context.Architecture, recipe.Actions.Architecture)
}
for _, a := range recipe.Actions.Actions {
- if err := a.Verify(context); err != nil {
+ if err := a.Verify(&recipe.context); err != nil {
return err
}
}
@@ -81,8 +84,10 @@ func (recipe *RecipeAction) Verify(context *debos.DebosContext) error {
func (recipe *RecipeAction) PreMachine(context *debos.DebosContext, m *fakemachine.Machine, args *[]string) error {
// TODO: check args?
+ m.AddVolume(recipe.context.RecipeDir)
+
for _, a := range recipe.Actions.Actions {
- if err := a.PreMachine(context, m, args); err != nil {
+ if err := a.PreMachine(&recipe.context, m, args); err != nil {
return err
}
}
@@ -92,7 +97,7 @@ func (recipe *RecipeAction) PreMachine(context *debos.DebosContext, m *fakemachi
func (recipe *RecipeAction) PreNoMachine(context *debos.DebosContext) error {
for _, a := range recipe.Actions.Actions {
- if err := a.PreNoMachine(context); err != nil {
+ if err := a.PreNoMachine(&recipe.context); err != nil {
return err
}
}
@@ -104,7 +109,7 @@ func (recipe *RecipeAction) Run(context *debos.DebosContext) error {
recipe.LogStart()
for _, a := range recipe.Actions.Actions {
- if err := a.Run(context); err != nil {
+ if err := a.Run(&recipe.context); err != nil {
return err
}
}
@@ -114,7 +119,7 @@ func (recipe *RecipeAction) Run(context *debos.DebosContext) error {
func (recipe *RecipeAction) Cleanup(context *debos.DebosContext) error {
for _, a := range recipe.Actions.Actions {
- if err := a.Cleanup(context); err != nil {
+ if err := a.Cleanup(&recipe.context); err != nil {
return err
}
}
@@ -124,7 +129,7 @@ func (recipe *RecipeAction) Cleanup(context *debos.DebosContext) error {
func (recipe *RecipeAction) PostMachine(context *debos.DebosContext) error {
for _, a := range recipe.Actions.Actions {
- if err := a.PostMachine(context); err != nil {
+ if err := a.PostMachine(&recipe.context); err != nil {
return err
}
}
@@ -134,7 +139,7 @@ func (recipe *RecipeAction) PostMachine(context *debos.DebosContext) error {
func (recipe *RecipeAction) PostMachineCleanup(context *debos.DebosContext) error {
for _, a := range recipe.Actions.Actions {
- if err := a.PostMachineCleanup(context); err != nil {
+ if err := a.PostMachineCleanup(&recipe.context); err != nil {
return err
}
}