package runner import ( "fmt" "os/exec" ) // Runner takes a command with a set of arguments and runs them, // returning an error. type Runner interface { // Run runs the given command with arguments, returning an error. Run(cmdPath string, args ...string) error } type cmdRunner struct{} // NewCommandRunner returns a runner which runs commands inside // the container using os/exec. func NewCommandRunner() Runner { return &cmdRunner{} } func (*cmdRunner) Run(cmdPath string, args ...string) error { cmd := exec.Command(cmdPath, args...) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("%s: %w", output, err) } return nil }