feat: added Init() and Cleanup() in hooks
This commit is contained in:
parent
bdd85b01ff
commit
277de43a02
2 changed files with 24 additions and 0 deletions
|
|
@ -133,10 +133,18 @@ func addToArchive(tw *tar.Writer, filename string, hooks []makeshift.Hook) error
|
||||||
}
|
}
|
||||||
hook.Data.Set("file", contents)
|
hook.Data.Set("file", contents)
|
||||||
|
|
||||||
|
err = hook.Init()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
err = hook.Run()
|
err = hook.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = hook.Cleanup()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// create temporary file to use to add to archive
|
// create temporary file to use to add to archive
|
||||||
hook = hooks[len(hooks)-1]
|
hook = hooks[len(hooks)-1]
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,14 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
"version": hook.Plugin.Version(),
|
"version": hook.Plugin.Version(),
|
||||||
},
|
},
|
||||||
}).Send()
|
}).Send()
|
||||||
|
err = hook.Init()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
Err(err).
|
||||||
|
Str("plugin", hook.Plugin.Name()).
|
||||||
|
Msg("failed to initialize plugin")
|
||||||
|
continue
|
||||||
|
}
|
||||||
err = hook.Run()
|
err = hook.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
|
|
@ -150,6 +158,14 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
Msg("failed to run plugin")
|
Msg("failed to run plugin")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
err = hook.Cleanup()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
Err(err).
|
||||||
|
Str("plugin", hook.Plugin.Name()).
|
||||||
|
Msg("failed to cleanup plugin")
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// take the contents from the last hook and update files
|
// take the contents from the last hook and update files
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue