The commit adds the following modifications:
* Possibility to load hooks recursively from a directory
* Extraction of the loadinghook method in webhook.go
* Tests done on a fairly complex tree of directory
Allowing hooks to be loaded from a directory is a nice feature, as it
allows a better organisation/readibility of the hooks that we have.
The LoadFromDir method rely on LoadFromFile and is meant to be very
permissive, and will return errors only when no hooks have been loaded.
Otherwise it will simply return 'nil' and the potential issues/warnings
that happen during the loading of hooks (invalid file, invalid path,
issue opening, etc).
Two issues are addressed in this commit:
1. Instead of only sending the predefined environment arguments, this
commit appends the arguments to the existing OS environment. Fixes#53.
2. If an argument is not found in the payload, allow the command to run
and pass in an empty string as a placeholder. Fixes#54.
Additionally, I replaced `hook.ErrInvalidPayloadSignature` with a new
`SignatureError` type so that we can embed the signature in the error.
There's a lot in this commit.
1. Add `pass-environment-to-command` option that works much like
`pass-arguments-to-command`. You can see an example usage in the
"github" test case.
2. Add a test program called "hookecho" that is used to test the
webhook package instead of relying upon a system `echo` command.
3. Move hooks_test.json to a template so that we can update the path to
hookecho on the fly.
4. Don't return an error at the end of hook.MatchRule.Evaluate(). All
tests succeed for me now.