summaryrefslogtreecommitdiff
path: root/check.go
diff options
context:
space:
mode:
Diffstat (limited to 'check.go')
-rw-r--r--check.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/check.go b/check.go
index 702d46b..77cdd2e 100644
--- a/check.go
+++ b/check.go
@@ -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(),
+ }
}