separated github from post handler

This commit is contained in:
Adnan Hajdarevic 2015-02-24 16:52:55 +01:00
parent 478d189de8
commit a5d79fddd9
2 changed files with 78 additions and 29 deletions

View file

@ -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)
}
}
}