From eb1e8e884d92a7086af96663d0c658d838315490 Mon Sep 17 00:00:00 2001 From: unclejack Date: Mon, 30 Jun 2014 22:22:29 +0300 Subject: [PATCH] integration cli: add imageExists to docker utils Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- integration-cli/docker_utils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index cc45012437..22217e2f03 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -66,6 +66,15 @@ func deleteImages(images string) error { return err } +func imageExists(image string) error { + inspectCmd := exec.Command(dockerBinary, "inspect", image) + exitCode, err := runCommand(inspectCmd) + if exitCode != 0 && err == nil { + err = fmt.Errorf("couldn't find image '%s'", image) + } + return err +} + func cmd(t *testing.T, args ...string) (string, int, error) { out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...)) errorOut(err, t, fmt.Sprintf("'%s' failed with errors: %v (%v)", strings.Join(args, " "), err, out))