describing current functionality as tests

This commit is contained in:
Cedric Meury
2018-03-26 00:06:05 +02:00
parent 5aa7da98af
commit 6c6f300423
4 changed files with 234 additions and 13 deletions
+30
View File
@@ -0,0 +1,30 @@
package helmexec
import (
"io/ioutil"
"os"
"os/exec"
)
const (
tmpPrefix = "helmfile-"
tmpSuffix = "-exec"
)
type Runner interface {
Execute(cmd string, args []string) ([]byte, error)
}
type CliRunner struct {}
func (cli CliRunner) 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()
}