Skip to content

Commit

Permalink
fix: argument handling in exec probe
Browse files Browse the repository at this point in the history
  • Loading branch information
macrat committed May 3, 2021
1 parent af6768d commit c76d32a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions probe/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ func getStatusByMessage(message string, default_ store.Status) (replacedMessage
}

func ExecuteExternalCommand(ctx context.Context, r Reporter, target *url.URL, command string, argument, env []string) {
var cmd *exec.Cmd
if len(argument) > 0 {
cmd = exec.CommandContext(ctx, command, argument...)
} else {
cmd = exec.CommandContext(ctx, command)
}
cmd := exec.CommandContext(ctx, command, argument...)

cmd.Env = env

Expand Down Expand Up @@ -115,5 +110,9 @@ func (p ExecuteProbe) Check(ctx context.Context, r Reporter) {
ctx, cancel := context.WithTimeout(ctx, 60*time.Minute)
defer cancel()

ExecuteExternalCommand(ctx, r, p.target, p.target.Opaque, []string{p.target.Fragment}, p.env)
if p.target.Fragment != "" {
ExecuteExternalCommand(ctx, r, p.target, p.target.Opaque, []string{p.target.Fragment}, p.env)
} else {
ExecuteExternalCommand(ctx, r, p.target, p.target.Opaque, nil, p.env)
}
}

0 comments on commit c76d32a

Please sign in to comment.