diff options
Diffstat (limited to 'check.go')
| -rw-r--r-- | check.go | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -12,7 +12,13 @@ type check struct { Args []string } -func (c check) execute(ctx context.Context) (string, int) { +type checkResult struct { + name string + output string + status int +} + +func (c check) execute(ctx context.Context, name string) checkResult { cmd := exec.CommandContext(ctx, c.Plugin, c.Args...) var bytes bytes.Buffer @@ -21,9 +27,17 @@ func (c check) execute(ctx context.Context) (string, int) { if err := cmd.Run(); err != nil { if ctx.Err() == context.DeadlineExceeded { - return "Check command timed out", critical + return checkResult{ + name: name, + output: "Check command timed out", + status: critical, + } } } - return strings.TrimSuffix(bytes.String(), "\n"), cmd.ProcessState.ExitCode() + return checkResult{ + name: name, + output: strings.TrimSuffix(bytes.String(), "\n"), + status: cmd.ProcessState.ExitCode(), + } } |
