Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -87,12 +87,26 @@ func pullImageIfNotExist(image string) (err error) {
|
| 87 | 87 |
return |
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 |
+// deprecated, use dockerCmd instead |
|
| 90 | 91 |
func cmd(t *testing.T, args ...string) (string, int, error) {
|
| 92 |
+ return dockerCmd(t, args...) |
|
| 93 |
+} |
|
| 94 |
+ |
|
| 95 |
+func dockerCmd(t *testing.T, args ...string) (string, int, error) {
|
|
| 91 | 96 |
out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...)) |
| 92 | 97 |
errorOut(err, t, fmt.Sprintf("'%s' failed with errors: %v (%v)", strings.Join(args, " "), err, out))
|
| 93 | 98 |
return out, status, err |
| 94 | 99 |
} |
| 95 | 100 |
|
| 101 |
+// execute a docker command in a directory |
|
| 102 |
+func dockerCmdInDir(t *testing.T, path string, args ...string) (string, int, error) {
|
|
| 103 |
+ dockerCommand := exec.Command(dockerBinary, args...) |
|
| 104 |
+ dockerCommand.Dir = path |
|
| 105 |
+ out, status, err := runCommandWithOutput(dockerCommand) |
|
| 106 |
+ errorOut(err, t, fmt.Sprintf("'%s' failed with errors: %v (%v)", strings.Join(args, " "), err, out))
|
|
| 107 |
+ return out, status, err |
|
| 108 |
+} |
|
| 109 |
+ |
|
| 96 | 110 |
func findContainerIp(t *testing.T, id string) string {
|
| 97 | 111 |
cmd := exec.Command(dockerBinary, "inspect", "--format='{{ .NetworkSettings.IPAddress }}'", id)
|
| 98 | 112 |
out, _, err := runCommandWithOutput(cmd) |