|
|
|
|
@ -12,7 +12,7 @@ const HookProvision = "packer_provision"
|
|
|
|
|
// in. In addition to that, the Hook is given access to a UI so that it can
|
|
|
|
|
// output things to the user.
|
|
|
|
|
type Hook interface {
|
|
|
|
|
Run(string, Ui, Communicator, interface{})
|
|
|
|
|
Run(string, Ui, Communicator, interface{}) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A Hook implementation that dispatches based on an internal mapping.
|
|
|
|
|
@ -23,14 +23,18 @@ type DispatchHook struct {
|
|
|
|
|
// Runs the hook with the given name by dispatching it to the proper
|
|
|
|
|
// hooks if a mapping exists. If a mapping doesn't exist, then nothing
|
|
|
|
|
// happens.
|
|
|
|
|
func (h *DispatchHook) Run(name string, ui Ui, comm Communicator, data interface{}) {
|
|
|
|
|
func (h *DispatchHook) Run(name string, ui Ui, comm Communicator, data interface{}) error {
|
|
|
|
|
hooks, ok := h.Mapping[name]
|
|
|
|
|
if !ok {
|
|
|
|
|
// No hooks for that name. No problem.
|
|
|
|
|
return
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, hook := range hooks {
|
|
|
|
|
hook.Run(name, ui, comm, data)
|
|
|
|
|
if err := hook.Run(name, ui, comm, data); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|