mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-23 22:02:28 +00:00
separated github from post handler
This commit is contained in:
parent
478d189de8
commit
a5d79fddd9
2 changed files with 78 additions and 29 deletions
|
@ -14,6 +14,7 @@ type Hook struct {
|
|||
Command string `json:"command"`
|
||||
Cwd string `json:"cwd"`
|
||||
Secret string `json:"secret"`
|
||||
Args []string `json:"args"`
|
||||
Rule rules.Rule `json:"trigger-rule"`
|
||||
}
|
||||
|
||||
|
@ -49,6 +50,14 @@ func (h *Hook) UnmarshalJSON(j []byte) error {
|
|||
h.Secret = v.(string)
|
||||
}
|
||||
|
||||
if v, ok := m["args"]; ok {
|
||||
h.Args = make([]string, 0)
|
||||
|
||||
for i := range v.([]interface{}) {
|
||||
h.Args = append(h.Args, v.([]interface{})[i].(string))
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := m["trigger-rule"]; ok {
|
||||
rule := v.(map[string]interface{})
|
||||
|
||||
|
@ -150,5 +159,9 @@ func (h *Hooks) SetDefaults() {
|
|||
if h.list[i].Cwd == "" {
|
||||
h.list[i].Cwd = "."
|
||||
}
|
||||
|
||||
if h.list[i].Args == nil {
|
||||
h.list[i].Args = make([]string, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue