Skip to content

Commit

Permalink
output binary input
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Feb 3, 2023
1 parent 816b66d commit af5c120
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions resource3/plugins/binary/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (p Plugin) call(ctx context.Context, cmd string, req interface{}, resp inte
command.Dir = p.config.ResourcePlugin.Dir
logger.Infof(ctx, "call %s", command.String())

out, err := p.execCommand(command, req)
out, err := p.execCommand(ctx, command, req)
if err != nil {
logger.Error(ctx, err, string(out))
return err
Expand All @@ -31,11 +31,13 @@ func (p Plugin) call(ctx context.Context, cmd string, req interface{}, resp inte
return json.Unmarshal(out, resp)
}

func (p Plugin) execCommand(cmd *exec.Cmd, req interface{}) ([]byte, error) {
func (p Plugin) execCommand(ctx context.Context, cmd *exec.Cmd, req interface{}) ([]byte, error) {
logger := log.WithFunc("resource.binary.execCommand")
b, err := json.Marshal(req)
if err != nil {
return nil, err
}
logger.WithField("in", string(b)).Debug(ctx, "call params")
cmd.Stdin = bytes.NewBuffer(b)
return cmd.CombinedOutput()
}

0 comments on commit af5c120

Please sign in to comment.