mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-22 21:32:32 +00:00
return command output, pass whole payload as json to the command
This commit is contained in:
parent
f1ebc440a4
commit
9c545a745f
4 changed files with 94 additions and 44 deletions
25
hook/hook.go
25
hook/hook.go
|
@ -16,10 +16,11 @@ import (
|
|||
|
||||
// Constants used to specify the parameter source
|
||||
const (
|
||||
SourceHeader string = "header"
|
||||
SourceQuery string = "url"
|
||||
SourcePayload string = "payload"
|
||||
SourceString string = "string"
|
||||
SourceHeader string = "header"
|
||||
SourceQuery string = "url"
|
||||
SourcePayload string = "payload"
|
||||
SourceString string = "string"
|
||||
SourceEntirePayload string = "entire-payload"
|
||||
)
|
||||
|
||||
// CheckPayloadSignature calculates and verifies SHA1 signature of the given payload
|
||||
|
@ -151,6 +152,14 @@ func (ha *Argument) Get(headers, query, payload *map[string]interface{}) (string
|
|||
source = payload
|
||||
case SourceString:
|
||||
return ha.Name, true
|
||||
case SourceEntirePayload:
|
||||
r, err := json.Marshal(payload)
|
||||
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
|
||||
return string(r), true
|
||||
}
|
||||
|
||||
if source != nil {
|
||||
|
@ -166,6 +175,7 @@ type Hook struct {
|
|||
ExecuteCommand string `json:"execute-command"`
|
||||
CommandWorkingDirectory string `json:"command-working-directory"`
|
||||
ResponseMessage string `json:"response-message"`
|
||||
CaptureCommandOutput bool `json:"include-command-output-in-response"`
|
||||
PassArgumentsToCommand []Argument `json:"pass-arguments-to-command"`
|
||||
JSONStringParameters []Argument `json:"parse-parameters-as-json"`
|
||||
TriggerRule *Rules `json:"trigger-rule"`
|
||||
|
@ -385,3 +395,10 @@ func (r MatchRule) Evaluate(headers, query, payload *map[string]interface{}, bod
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// CommandStatusResponse type encapsulates the executed command exit code, message, stdout and stderr
|
||||
type CommandStatusResponse struct {
|
||||
ResponseMessage string `json:"message"`
|
||||
Output string `json:"output"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue