Commit 25fd2fe8 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: Template looks up hooks and adds them to the build

parent 779f4898
......@@ -17,7 +17,7 @@ type Build interface {
type coreBuild struct {
name string
builder Builder
hooks map[string]Hook
hooks map[string][]Hook
rawConfig interface{}
prepareCalled bool
......
......@@ -113,9 +113,32 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
return
}
hooks := make(map[string][]Hook)
for tplEvent, tplHooks := range t.Hooks {
curHooks := make([]Hook, 0, len(tplHooks))
for _, hookName := range tplHooks {
var hook Hook
hook, err = components.Hook(hookName)
if err != nil {
return
}
if hook == nil {
err = fmt.Errorf("Hook not found: %s", hookName)
return
}
curHooks = append(curHooks, hook)
}
hooks[tplEvent] = curHooks
}
b = &coreBuild{
name: name,
builder: builder,
hooks: hooks,
rawConfig: builderConfig.rawConfig,
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment