summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorAndrej Shadura <andrew.shadura@collabora.co.uk>2019-03-26 16:06:59 +0100
committerAndrej Shadura <andrew.shadura@collabora.co.uk>2019-03-26 16:06:59 +0100
commita3b702fbbd38e925aaf0186c16bf4fc794741f0e (patch)
treea7a6e9e3e59bf92fec432a3c425dd1abc2f10b4b /actions
parent5669c9ce6d8c817d6f3c04196e2cf59827e447d3 (diff)
parenta5b1ffcadfa25582fa8364b73524bfff3e2a274b (diff)
Update upstream source from tag 'upstream/1.0.0+git20190326.5bd4aa9'
Update to upstream version '1.0.0+git20190326.5bd4aa9' with Debian dir 2d4a1a0652c121b2ad5ad91411cbb63c04958fc1
Diffstat (limited to 'actions')
-rw-r--r--actions/recipe_action.go23
-rw-r--r--actions/recipe_test.go7
2 files changed, 15 insertions, 15 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
}
}
diff --git a/actions/recipe_test.go b/actions/recipe_test.go
index 972bf61..de9d6ea 100644
--- a/actions/recipe_test.go
+++ b/actions/recipe_test.go
@@ -231,16 +231,11 @@ actions:
var recipeIncluded = subRecipe {
"included.yaml",
`
-{{- $included_recipe := or .included_recipe "false"}}
architecture: amd64
actions:
- action: run
command: ok.sh
- {{- if ne $included_recipe "true" }}
- - action: recipe
- recipe: armhf.yaml
- {{- end }}
`,
}
@@ -314,7 +309,7 @@ actions:
}
func runTestWithSubRecipes(t *testing.T, test testSubRecipe, templateVars ...map[string]string) actions.Recipe {
- var context debos.DebosContext
+ context := debos.DebosContext { &debos.CommonContext{}, "", "" }
dir, err := ioutil.TempDir("", "go-debos")
assert.Empty(t, err)
defer os.RemoveAll(dir)