The `context-provider-command` allows user to specify a command which will be run whenever the hook gets matched.
Webhook will pass the command a JSON string via the STDIN containing the request context (matched hook id, method used to trigger the hook, remote address, requested host, requested URI, raw body, headers and query values).
The output of the command must be a valid JSON string which will be mapped back into a special source named `context` that can be used with existing rules and directives.
Add a -template command line option that instructs webhook to parse the
hooks files as Go text templates.
Includes a `getenv` template func for retrieving environment variables.
* Adding ignore patterns
* Adding support for env var naming
* Fixed typo in docstring
* Adding tests for the env var extraction w & w/o explicit naming
* remove coverage script from ignore patterns
* Adding the coverage script to help see which code is tested and which is not
* remove coverage script from sources
* Ignore coverage script from sources tree
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.
The hook package should be self-contained and return errors instead of
relying on the log subsystem. This commit removes the logging
side-effects from the hook package. Custom errors are returned that
should be transparent to the caller -- they can just treat them as
simple errors if they don't care to check the type.