Browse code

integration cli: add imageExists to docker utils

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

unclejack authored on 2014/07/01 04:22:29
Showing 1 changed files
... ...
@@ -66,6 +66,15 @@ func deleteImages(images string) error {
66 66
 	return err
67 67
 }
68 68
 
69
+func imageExists(image string) error {
70
+	inspectCmd := exec.Command(dockerBinary, "inspect", image)
71
+	exitCode, err := runCommand(inspectCmd)
72
+	if exitCode != 0 && err == nil {
73
+		err = fmt.Errorf("couldn't find image '%s'", image)
74
+	}
75
+	return err
76
+}
77
+
69 78
 func cmd(t *testing.T, args ...string) (string, int, error) {
70 79
 	out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...))
71 80
 	errorOut(err, t, fmt.Sprintf("'%s' failed with errors: %v (%v)", strings.Join(args, " "), err, out))