github.com/argoproj/argo-cd@v1.8.7/test/e2e/fixture/cmd.go (about) 1 package fixture 2 3 import ( 4 "os" 5 "os/exec" 6 "strings" 7 8 argoexec "github.com/argoproj/pkg/exec" 9 ) 10 11 func Run(workDir, name string, args ...string) (string, error) { 12 return RunWithStdin("", workDir, name, args...) 13 } 14 15 func RunWithStdin(stdin, workDir, name string, args ...string) (string, error) { 16 cmd := exec.Command(name, args...) 17 if stdin != "" { 18 cmd.Stdin = strings.NewReader(stdin) 19 } 20 cmd.Env = os.Environ() 21 cmd.Dir = workDir 22 23 return argoexec.RunCommandExt(cmd, argoexec.CmdOpts{}) 24 }