mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-12 16:44:43 +00:00
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.
26 lines
416 B
Go
26 lines
416 B
Go
// Hook Echo is a simply utility used for testing the Webhook package.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) > 1 {
|
|
fmt.Printf("arg: %s\n", strings.Join(os.Args[1:], " "))
|
|
}
|
|
|
|
var env []string
|
|
for _, v := range os.Environ() {
|
|
if strings.HasPrefix(v, "HOOK_") {
|
|
env = append(env, v)
|
|
}
|
|
}
|
|
|
|
if len(env) > 0 {
|
|
fmt.Printf("env: %s\n", strings.Join(env, " "))
|
|
}
|
|
}
|