Skip to content

Commit

Permalink
Add support for passing payload to command STDIN
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosbarreto committed May 3, 2018
1 parent 80f2222 commit 92e0b05
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions builtin/bins/dkron-executor-shell/shell.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"encoding/base64"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -54,6 +55,21 @@ func (s *Shell) Execute(args *dkron.ExecuteRequest) ([]byte, error) {
})
defer slowTimer.Stop()

stdin, err := cmd.StdinPipe()
if err != nil {
return nil, err
}

defer stdin.Close()

payload, err := base64.StdEncoding.DecodeString(args.Config["payload"])
if err != nil {
return nil, err
}

stdin.Write(payload)
stdin.Close()

log.Printf("shell: going to run %s", command)
err = cmd.Start()
if err != nil {
Expand Down

0 comments on commit 92e0b05

Please sign in to comment.