mirror of
https://github.com/tendermint/tendermint.git
synced 2026-04-15 21:27:06 +00:00
Extract Docker-specific functionality and put it behind an interface that should hopefully, without too much modification, allow us to implement a Digital Ocean-based infrastructure provider. Signed-off-by: Thane Thomson <connect@thanethomson.com>
31 lines
616 B
Go
31 lines
616 B
Go
//nolint: gosec
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
osexec "os/exec"
|
|
)
|
|
|
|
// execute executes a shell command.
|
|
func exec(args ...string) error {
|
|
cmd := osexec.Command(args[0], args[1:]...)
|
|
out, err := cmd.CombinedOutput()
|
|
switch err := err.(type) {
|
|
case nil:
|
|
return nil
|
|
case *osexec.ExitError:
|
|
return fmt.Errorf("failed to run %q:\n%v", args, string(out))
|
|
default:
|
|
return err
|
|
}
|
|
}
|
|
|
|
// execVerbose executes a shell command while displaying its output.
|
|
func execVerbose(args ...string) error {
|
|
cmd := osexec.Command(args[0], args[1:]...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
return cmd.Run()
|
|
}
|