mirror of
https://github.com/adnanh/webhook.git
synced 2026-07-26 17:10:45 +08:00
Allow hookecho to exit with codes other than 0
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
.cover
|
.cover
|
||||||
coverage
|
coverage
|
||||||
webhook
|
webhook
|
||||||
|
/test/hookecho
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -23,4 +24,14 @@ func main() {
|
|||||||
if len(env) > 0 {
|
if len(env) > 0 {
|
||||||
fmt.Printf("env: %s\n", strings.Join(env, " "))
|
fmt.Printf("env: %s\n", strings.Join(env, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len(os.Args) > 1) && (strings.HasPrefix(os.Args[1], "exit=")) {
|
||||||
|
exit_code_str := os.Args[1][5:]
|
||||||
|
exit_code, err := strconv.Atoi(exit_code_str)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Exit code %s not an int!", exit_code_str)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
os.Exit(exit_code)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user