RunCallback invokes a callback with the given name if it exists for the plugin
(name string, arguments []string, environment map[string]string, stdOut io.Writer, errOut io.Writer)
| 178 | |
| 179 | // RunCallback invokes a callback with the given name if it exists for the plugin |
| 180 | func (p Plugin) RunCallback(name string, arguments []string, environment map[string]string, stdOut io.Writer, errOut io.Writer) error { |
| 181 | callback, err := p.CallbackPath(name) |
| 182 | if err != nil { |
| 183 | return err |
| 184 | } |
| 185 | |
| 186 | cmd := execute.New(fmt.Sprintf("'%s'", callback), arguments) |
| 187 | |
| 188 | cmd.Env = environment |
| 189 | cmd.Stdout = stdOut |
| 190 | cmd.Stderr = errOut |
| 191 | |
| 192 | return cmd.Run() |
| 193 | } |
| 194 | |
| 195 | // CallbackPath returns the full file path to a callback script |
| 196 | func (p Plugin) CallbackPath(name string) (string, error) { |