RunCommand starts the hook command and returns the action
()
| 85 | |
| 86 | // RunCommand starts the hook command and returns the action |
| 87 | func (a *HookAuth) RunCommand() (string, error) { |
| 88 | command := strings.Split(a.Command, " ") |
| 89 | |
| 90 | cmd := exec.Command(command[0], command[1:]...) |
| 91 | cmd.Env = append(os.Environ(), fmt.Sprintf("USERNAME=%s", a.Cred.Username)) |
| 92 | cmd.Env = append(cmd.Env, fmt.Sprintf("PASSWORD=%s", a.Cred.Password)) |
| 93 | out, err := cmd.Output() |
| 94 | if err != nil { |
| 95 | return "", err |
| 96 | } |
| 97 | |
| 98 | a.GetValues(string(out)) |
| 99 | |
| 100 | return a.Fields.Values["hook.action"], nil |
| 101 | } |
| 102 | |
| 103 | // GetValues creates a map with values from the key-value format string |
| 104 | func (a *HookAuth) GetValues(s string) { |