summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAlex Goodman <wagoodman@gmail.com>2018-10-20 07:42:01 -0400
committerAlex Goodman <wagoodman@gmail.com>2018-10-20 07:42:01 -0400
commitd6549ea16d45c9a839cbabcdefc7afb473f9e146 (patch)
tree583e3ab00b3e773412c229416bdacd91b9f5c7c0 /utils
parent4195374c5b12d4e126bc26f7484d500b981c8930 (diff)
pull images when not found (closes #25); small fixes
Diffstat (limited to 'utils')
-rw-r--r--utils/docker.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/utils/docker.go b/utils/docker.go
new file mode 100644
index 0000000..339b0a9
--- /dev/null
+++ b/utils/docker.go
@@ -0,0 +1,33 @@
+package utils
+
+import (
+ "os/exec"
+ "os"
+ "strings"
+)
+
+// RunDockerCmd runs a given Docker command in the current tty
+func RunDockerCmd(cmdStr string, args ...string) error {
+
+ allArgs := cleanArgs(append([]string{cmdStr}, args...))
+
+ cmd := exec.Command("docker", allArgs...)
+
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ cmd.Stdin = os.Stdin
+
+ return cmd.Run()
+}
+
+// cleanArgs trims the whitespace from the given set of strings.
+func cleanArgs(s []string) []string {
+ var r []string
+ for _, str := range s {
+ if str != "" {
+ r = append(r, strings.Trim(str, " "))
+ }
+ }
+ return r
+}
+