| 14 | ) |
| 15 | |
| 16 | func runExecutable(root, executable string, env []string, stdin string, arg ...string) hookResult { |
| 17 | dir, command := path.Split(executable) |
| 18 | span := tracing.NewSpan(fmt.Sprintf("hook %s %s", path.Base(dir), command)) |
| 19 | defer span.End() |
| 20 | cmd := exec.Command(path.Join(root, executable), arg...) |
| 21 | cmd.Env = append(os.Environ(), env...) |
| 22 | cmd.Stdin = strings.NewReader(stdin) |
| 23 | var stderr bytes.Buffer |
| 24 | cmd.Stderr = &stderr |
| 25 | stdout, err := cmd.Output() |
| 26 | return hookResult{ |
| 27 | executable: executable, |
| 28 | stdout: string(stdout), |
| 29 | stderr: stderr.String(), |
| 30 | err: err, |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | type hookResult struct { |
| 35 | executable string |