Files
helmfile/helmexec/runner.go
T
Shane Starcher 71fa693997 templating the entire helmfile and adding some documentation (#98)
* templating the entire helmfile and adding some documentation

* updating vendor and using dep

* update to golang 1.10

* updating docs
2018-04-10 20:19:43 +09:00

34 lines
640 B
Go

package helmexec
import (
"io/ioutil"
"os"
"os/exec"
)
const (
tmpPrefix = "helmfile-"
tmpSuffix = "-exec"
)
// Runner interface for shell commands
type Runner interface {
Execute(cmd string, args []string) ([]byte, error)
}
// ShellRunner implemention for shell commands
type ShellRunner struct{}
// Execute a shell command
func (shell ShellRunner) Execute(cmd string, args []string) ([]byte, error) {
dir, err := ioutil.TempDir("", tmpPrefix+cmd+tmpSuffix)
if err != nil {
return nil, err
}
defer os.RemoveAll(dir)
preparedCmd := exec.Command(cmd, args...)
preparedCmd.Dir = dir
return preparedCmd.CombinedOutput()
}