1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12466 from robertabbott/fix_dockerCmd

Removed unnecessary error output from dockerCmd
This commit is contained in:
Arnaud Porterie 2015-04-17 15:15:34 -07:00
commit 5fd378c0d1
16 changed files with 127 additions and 176 deletions

View file

@ -627,7 +627,7 @@ func TestContainerApiPause(t *testing.T) {
func TestContainerApiTop(t *testing.T) { func TestContainerApiTop(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
out, _, _ := dockerCmd(t, "run", "-d", "-i", "busybox", "/bin/sh", "-c", "cat") out, _ := dockerCmd(t, "run", "-d", "-i", "busybox", "/bin/sh", "-c", "cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
if err := waitRun(id); err != nil { if err := waitRun(id); err != nil {
t.Fatal(err) t.Fatal(err)
@ -667,7 +667,7 @@ func TestContainerApiTop(t *testing.T) {
} }
func TestContainerApiCommit(t *testing.T) { func TestContainerApiCommit(t *testing.T) {
out, _, _ := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test") out, _ := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
name := "testcommit" name := "testcommit"
@ -714,7 +714,7 @@ func TestContainerApiCreate(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
out, _, _ := dockerCmd(t, "start", "-a", container.Id) out, _ := dockerCmd(t, "start", "-a", container.Id)
if strings.TrimSpace(out) != "/test" { if strings.TrimSpace(out) != "/test" {
t.Fatalf("expected output `/test`, got %q", out) t.Fatalf("expected output `/test`, got %q", out)
} }

View file

@ -91,7 +91,7 @@ func TestApiImagesSaveAndLoad(t *testing.T) {
} }
defer loadBody.Close() defer loadBody.Close()
out, _, _ = dockerCmd(t, "inspect", "--format='{{ .Id }}'", id) out, _ = dockerCmd(t, "inspect", "--format='{{ .Id }}'", id)
if strings.TrimSpace(out) != id { if strings.TrimSpace(out) != id {
t.Fatal("load did not work properly") t.Fatal("load did not work properly")
} }

View file

@ -138,7 +138,7 @@ func TestAttachTtyWithoutStdin(t *testing.T) {
func TestAttachDisconnect(t *testing.T) { func TestAttachDisconnect(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
out, _, _ := dockerCmd(t, "run", "-di", "busybox", "/bin/cat") out, _ := dockerCmd(t, "run", "-di", "busybox", "/bin/cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
cmd := exec.Command(dockerBinary, "attach", id) cmd := exec.Command(dockerBinary, "attach", id)

View file

@ -142,7 +142,7 @@ func TestAttachAfterDetach(t *testing.T) {
// TestAttachDetach checks that attach in tty mode can be detached using the long container ID // TestAttachDetach checks that attach in tty mode can be detached using the long container ID
func TestAttachDetach(t *testing.T) { func TestAttachDetach(t *testing.T) {
out, _, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") out, _ := dockerCmd(t, "run", "-itd", "busybox", "cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
if err := waitRun(id); err != nil { if err := waitRun(id); err != nil {
t.Fatal(err) t.Fatal(err)
@ -217,7 +217,7 @@ func TestAttachDetach(t *testing.T) {
// TestAttachDetachTruncatedID checks that attach in tty mode can be detached // TestAttachDetachTruncatedID checks that attach in tty mode can be detached
func TestAttachDetachTruncatedID(t *testing.T) { func TestAttachDetachTruncatedID(t *testing.T) {
out, _, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") out, _ := dockerCmd(t, "run", "-itd", "busybox", "cat")
id := stringid.TruncateID(strings.TrimSpace(out)) id := stringid.TruncateID(strings.TrimSpace(out))
if err := waitRun(id); err != nil { if err := waitRun(id); err != nil {
t.Fatal(err) t.Fatal(err)

View file

@ -3294,7 +3294,7 @@ func TestBuildNoContext(t *testing.T) {
t.Fatalf("build failed to complete: %v %v", out, err) t.Fatalf("build failed to complete: %v %v", out, err)
} }
if out, _, err := dockerCmd(t, "run", "--rm", "nocontext"); out != "ok\n" || err != nil { if out, _ := dockerCmd(t, "run", "--rm", "nocontext"); out != "ok\n" {
t.Fatalf("run produced invalid output: %q, expected %q", out, "ok") t.Fatalf("run produced invalid output: %q, expected %q", out, "ok")
} }
@ -5562,10 +5562,7 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err, out) t.Fatal(err, out)
} }
out, _, err = dockerCmd(t, "ps", "-lq") out, _ = dockerCmd(t, "ps", "-lq")
if err != nil {
t.Fatal(err, out)
}
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
@ -5593,10 +5590,8 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
} }
// Make sure constraints aren't saved to image // Make sure constraints aren't saved to image
_, _, err = dockerCmd(t, "run", "--name=test", name) _, _ = dockerCmd(t, "run", "--name=test", name)
if err != nil {
t.Fatal(err)
}
cfg, err = inspectFieldJSON("test", "HostConfig") cfg, err = inspectFieldJSON("test", "HostConfig")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View file

@ -284,13 +284,13 @@ func TestCommitChange(t *testing.T) {
func TestCommitMergeConfigRun(t *testing.T) { func TestCommitMergeConfigRun(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
name := "commit-test" name := "commit-test"
out, _, _ := dockerCmd(t, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo") out, _ := dockerCmd(t, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
dockerCmd(t, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test") dockerCmd(t, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test")
defer deleteImages("commit-test") defer deleteImages("commit-test")
out, _, _ = dockerCmd(t, "run", "--name", name, "commit-test") out, _ = dockerCmd(t, "run", "--name", name, "commit-test")
if strings.TrimSpace(out) != "testing" { if strings.TrimSpace(out) != "testing" {
t.Fatal("run config in commited container was not merged") t.Fatal("run config in commited container was not merged")
} }

View file

@ -25,17 +25,17 @@ const (
// Test for #5656 // Test for #5656
// Check that garbage paths don't escape the container's rootfs // Check that garbage paths don't escape the container's rootfs
func TestCpGarbagePath(t *testing.T) { func TestCpGarbagePath(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
@ -61,10 +61,7 @@ func TestCpGarbagePath(t *testing.T) {
path := path.Join("../../../../../../../../../../../../", cpFullPath) path := path.Join("../../../../../../../../../../../../", cpFullPath)
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
t.Fatalf("couldn't copy from garbage path: %s:%s %s", cleanedContainerID, path, err)
}
file, _ := os.Open(tmpname) file, _ := os.Open(tmpname)
defer file.Close() defer file.Close()
@ -87,17 +84,17 @@ func TestCpGarbagePath(t *testing.T) {
// Check that relative paths are relative to the container's rootfs // Check that relative paths are relative to the container's rootfs
func TestCpRelativePath(t *testing.T) { func TestCpRelativePath(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
@ -131,10 +128,7 @@ func TestCpRelativePath(t *testing.T) {
t.Fatalf("path %s was assumed to be an absolute path", cpFullPath) t.Fatalf("path %s was assumed to be an absolute path", cpFullPath)
} }
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+relPath, tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+relPath, tmpdir)
if err != nil {
t.Fatalf("couldn't copy from relative path: %s:%s %s", cleanedContainerID, relPath, err)
}
file, _ := os.Open(tmpname) file, _ := os.Open(tmpname)
defer file.Close() defer file.Close()
@ -157,17 +151,17 @@ func TestCpRelativePath(t *testing.T) {
// Check that absolute paths are relative to the container's rootfs // Check that absolute paths are relative to the container's rootfs
func TestCpAbsolutePath(t *testing.T) { func TestCpAbsolutePath(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
@ -194,10 +188,7 @@ func TestCpAbsolutePath(t *testing.T) {
path := cpFullPath path := cpFullPath
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
t.Fatalf("couldn't copy from absolute path: %s:%s %s", cleanedContainerID, path, err)
}
file, _ := os.Open(tmpname) file, _ := os.Open(tmpname)
defer file.Close() defer file.Close()
@ -221,17 +212,17 @@ func TestCpAbsolutePath(t *testing.T) {
// Test for #5619 // Test for #5619
// Check that absolute symlinks are still relative to the container's rootfs // Check that absolute symlinks are still relative to the container's rootfs
func TestCpAbsoluteSymlink(t *testing.T) { func TestCpAbsoluteSymlink(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
@ -258,10 +249,7 @@ func TestCpAbsoluteSymlink(t *testing.T) {
path := path.Join("/", "container_path") path := path.Join("/", "container_path")
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
t.Fatalf("couldn't copy from absolute path: %s:%s %s", cleanedContainerID, path, err)
}
file, _ := os.Open(tmpname) file, _ := os.Open(tmpname)
defer file.Close() defer file.Close()
@ -285,17 +273,17 @@ func TestCpAbsoluteSymlink(t *testing.T) {
// Test for #5619 // Test for #5619
// Check that symlinks which are part of the resource path are still relative to the container's rootfs // Check that symlinks which are part of the resource path are still relative to the container's rootfs
func TestCpSymlinkComponent(t *testing.T) { func TestCpSymlinkComponent(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
@ -322,10 +310,7 @@ func TestCpSymlinkComponent(t *testing.T) {
path := path.Join("/", "container_path", cpTestName) path := path.Join("/", "container_path", cpTestName)
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
t.Fatalf("couldn't copy from symlink path component: %s:%s %s", cleanedContainerID, path, err)
}
file, _ := os.Open(tmpname) file, _ := os.Open(tmpname)
defer file.Close() defer file.Close()
@ -350,17 +335,17 @@ func TestCpSymlinkComponent(t *testing.T) {
func TestCpUnprivilegedUser(t *testing.T) { func TestCpUnprivilegedUser(t *testing.T) {
testRequires(t, UnixCli) // uses chmod/su: not available on windows testRequires(t, UnixCli) // uses chmod/su: not available on windows
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName) out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName)
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
tmpdir, err := ioutil.TempDir("", "docker-integration") tmpdir, err := ioutil.TempDir("", "docker-integration")
@ -393,24 +378,21 @@ func TestCpSpecialFiles(t *testing.T) {
} }
defer os.RemoveAll(outDir) defer os.RemoveAll(outDir)
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /foo") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /foo")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
// Copy actual /etc/resolv.conf // Copy actual /etc/resolv.conf
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/resolv.conf", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/resolv.conf", outDir)
if err != nil {
t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/resolv.conf", err)
}
expected, err := ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/resolv.conf") expected, err := ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/resolv.conf")
actual, err := ioutil.ReadFile(outDir + "/resolv.conf") actual, err := ioutil.ReadFile(outDir + "/resolv.conf")
@ -420,10 +402,7 @@ func TestCpSpecialFiles(t *testing.T) {
} }
// Copy actual /etc/hosts // Copy actual /etc/hosts
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/hosts", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/hosts", outDir)
if err != nil {
t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/hosts", err)
}
expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hosts") expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hosts")
actual, err = ioutil.ReadFile(outDir + "/hosts") actual, err = ioutil.ReadFile(outDir + "/hosts")
@ -433,10 +412,7 @@ func TestCpSpecialFiles(t *testing.T) {
} }
// Copy actual /etc/resolv.conf // Copy actual /etc/resolv.conf
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/hostname", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/hostname", outDir)
if err != nil {
t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/hostname", err)
}
expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hostname") expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hostname")
actual, err = ioutil.ReadFile(outDir + "/hostname") actual, err = ioutil.ReadFile(outDir + "/hostname")
@ -466,24 +442,22 @@ func TestCpVolumePath(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
out, exitCode, err := dockerCmd(t, "run", "-d", "-v", "/foo", "-v", tmpDir+"/test:/test", "-v", tmpDir+":/baz", "busybox", "/bin/sh", "-c", "touch /foo/bar") out, exitCode := dockerCmd(t, "run", "-d", "-v", "/foo", "-v", tmpDir+"/test:/test", "-v", tmpDir+":/baz", "busybox", "/bin/sh", "-c", "touch /foo/bar")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer dockerCmd(t, "rm", "-fv", cleanedContainerID) defer dockerCmd(t, "rm", "-fv", cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
// Copy actual volume path // Copy actual volume path
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/foo", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/foo", outDir)
if err != nil {
t.Fatalf("couldn't copy from volume path: %s:%s %v", cleanedContainerID, "/foo", err)
}
stat, err := os.Stat(outDir + "/foo") stat, err := os.Stat(outDir + "/foo")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -500,10 +474,8 @@ func TestCpVolumePath(t *testing.T) {
} }
// Copy file nested in volume // Copy file nested in volume
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/foo/bar", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/foo/bar", outDir)
if err != nil {
t.Fatalf("couldn't copy from volume path: %s:%s %v", cleanedContainerID, "/foo", err)
}
stat, err = os.Stat(outDir + "/bar") stat, err = os.Stat(outDir + "/bar")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -513,10 +485,7 @@ func TestCpVolumePath(t *testing.T) {
} }
// Copy Bind-mounted dir // Copy Bind-mounted dir
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/baz", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/baz", outDir)
if err != nil {
t.Fatalf("couldn't copy from bind-mounted volume path: %s:%s %v", cleanedContainerID, "/baz", err)
}
stat, err = os.Stat(outDir + "/baz") stat, err = os.Stat(outDir + "/baz")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -526,7 +495,7 @@ func TestCpVolumePath(t *testing.T) {
} }
// Copy file nested in bind-mounted dir // Copy file nested in bind-mounted dir
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/baz/test", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/baz/test", outDir)
fb, err := ioutil.ReadFile(outDir + "/baz/test") fb, err := ioutil.ReadFile(outDir + "/baz/test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -540,7 +509,7 @@ func TestCpVolumePath(t *testing.T) {
} }
// Copy bind-mounted file // Copy bind-mounted file
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/test", outDir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/test", outDir)
fb, err = ioutil.ReadFile(outDir + "/test") fb, err = ioutil.ReadFile(outDir + "/test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -557,17 +526,17 @@ func TestCpVolumePath(t *testing.T) {
} }
func TestCpToDot(t *testing.T) { func TestCpToDot(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
tmpdir, err := ioutil.TempDir("", "docker-integration") tmpdir, err := ioutil.TempDir("", "docker-integration")
@ -583,10 +552,7 @@ func TestCpToDot(t *testing.T) {
if err := os.Chdir(tmpdir); err != nil { if err := os.Chdir(tmpdir); err != nil {
t.Fatal(err) t.Fatal(err)
} }
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/test", ".") _, _ = dockerCmd(t, "cp", cleanedContainerID+":/test", ".")
if err != nil {
t.Fatalf("couldn't docker cp to \".\" path: %s", err)
}
content, err := ioutil.ReadFile("./test") content, err := ioutil.ReadFile("./test")
if string(content) != "lololol\n" { if string(content) != "lololol\n" {
t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n") t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n")
@ -595,22 +561,23 @@ func TestCpToDot(t *testing.T) {
} }
func TestCpToStdout(t *testing.T) { func TestCpToStdout(t *testing.T) {
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatalf("failed to create a container:%s\n%s", out, err) t.Fatalf("failed to create a container:%s\n", out)
} }
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
defer deleteContainer(cID) defer deleteContainer(cID)
out, _, err = dockerCmd(t, "wait", cID) out, _ = dockerCmd(t, "wait", cID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatalf("failed to set up container:%s\n%s", out, err) t.Fatalf("failed to set up container:%s\n", out)
} }
out, _, err = runCommandPipelineWithOutput( out, _, err := runCommandPipelineWithOutput(
exec.Command(dockerBinary, "cp", cID+":/test", "-"), exec.Command(dockerBinary, "cp", cID+":/test", "-"),
exec.Command("tar", "-vtf", "-")) exec.Command("tar", "-vtf", "-"))
if err != nil { if err != nil {
t.Fatalf("Failed to run commands: %s", err) t.Fatalf("Failed to run commands: %s", err)
} }
@ -624,17 +591,17 @@ func TestCpToStdout(t *testing.T) {
func TestCpNameHasColon(t *testing.T) { func TestCpNameHasColon(t *testing.T) {
testRequires(t, SameHostDaemon) testRequires(t, SameHostDaemon)
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t") out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t")
if err != nil || exitCode != 0 { if exitCode != 0 {
t.Fatal("failed to create a container", out, err) t.Fatal("failed to create a container", out)
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
defer deleteContainer(cleanedContainerID) defer deleteContainer(cleanedContainerID)
out, _, err = dockerCmd(t, "wait", cleanedContainerID) out, _ = dockerCmd(t, "wait", cleanedContainerID)
if err != nil || strings.TrimSpace(out) != "0" { if strings.TrimSpace(out) != "0" {
t.Fatal("failed to set up container", out, err) t.Fatal("failed to set up container", out)
} }
tmpdir, err := ioutil.TempDir("", "docker-integration") tmpdir, err := ioutil.TempDir("", "docker-integration")
@ -642,10 +609,7 @@ func TestCpNameHasColon(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
defer os.RemoveAll(tmpdir) defer os.RemoveAll(tmpdir)
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":/te:s:t", tmpdir) _, _ = dockerCmd(t, "cp", cleanedContainerID+":/te:s:t", tmpdir)
if err != nil {
t.Fatalf("couldn't docker cp to %s: %s", tmpdir, err)
}
content, err := ioutil.ReadFile(tmpdir + "/te:s:t") content, err := ioutil.ReadFile(tmpdir + "/te:s:t")
if string(content) != "lololol\n" { if string(content) != "lololol\n" {
t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n") t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n")

View file

@ -307,7 +307,7 @@ func TestCreateLabelFromImage(t *testing.T) {
} }
func TestCreateHostnameWithNumber(t *testing.T) { func TestCreateHostnameWithNumber(t *testing.T) {
out, _, _ := dockerCmd(t, "run", "-h", "web.0", "busybox", "hostname") out, _ := dockerCmd(t, "run", "-h", "web.0", "busybox", "hostname")
if strings.TrimSpace(out) != "web.0" { if strings.TrimSpace(out) != "web.0" {
t.Fatalf("hostname not set, expected `web.0`, got: %s", out) t.Fatalf("hostname not set, expected `web.0`, got: %s", out)
} }

View file

@ -38,7 +38,7 @@ func TestEventsUntag(t *testing.T) {
func TestEventsContainerFailStartDie(t *testing.T) { func TestEventsContainerFailStartDie(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
out, _, _ := dockerCmd(t, "images", "-q") out, _ := dockerCmd(t, "images", "-q")
image := strings.Split(out, "\n")[0] image := strings.Split(out, "\n")[0]
eventsCmd := exec.Command(dockerBinary, "run", "--name", "testeventdie", image, "blerg") eventsCmd := exec.Command(dockerBinary, "run", "--name", "testeventdie", image, "blerg")
_, _, err := runCommandWithOutput(eventsCmd) _, _, err := runCommandWithOutput(eventsCmd)

View file

@ -500,12 +500,12 @@ func TestLinksPingLinkedContainersOnRename(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
var out string var out string
out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") out, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out) idA := strings.TrimSpace(out)
if idA == "" { if idA == "" {
t.Fatal(out, "id should not be nil") t.Fatal(out, "id should not be nil")
} }
out, _, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top") out, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top")
idB := strings.TrimSpace(out) idB := strings.TrimSpace(out)
if idB == "" { if idB == "" {
t.Fatal(out, "id should not be nil") t.Fatal(out, "id should not be nil")

View file

@ -110,9 +110,9 @@ func TestLinksPingLinkedContainers(t *testing.T) {
func TestLinksPingLinkedContainersAfterRename(t *testing.T) { func TestLinksPingLinkedContainersAfterRename(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
out, _, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") out, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out) idA := strings.TrimSpace(out)
out, _, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top") out, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top")
idB := strings.TrimSpace(out) idB := strings.TrimSpace(out)
dockerCmd(t, "rename", "container1", "container_new") dockerCmd(t, "rename", "container1", "container_new")
dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1") dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")

View file

@ -12,7 +12,7 @@ func TestPause(t *testing.T) {
defer unpauseAllContainers() defer unpauseAllContainers()
name := "testeventpause" name := "testeventpause"
out, _, _ := dockerCmd(t, "images", "-q") out, _ := dockerCmd(t, "images", "-q")
image := strings.Split(out, "\n")[0] image := strings.Split(out, "\n")[0]
dockerCmd(t, "run", "-d", "--name", name, image, "top") dockerCmd(t, "run", "-d", "--name", name, image, "top")
@ -55,7 +55,7 @@ func TestPauseMultipleContainers(t *testing.T) {
"testpausewithmorecontainers1", "testpausewithmorecontainers1",
"testpausewithmorecontainers2", "testpausewithmorecontainers2",
} }
out, _, _ := dockerCmd(t, "images", "-q") out, _ := dockerCmd(t, "images", "-q")
image := strings.Split(out, "\n")[0] image := strings.Split(out, "\n")[0]
for _, name := range containers { for _, name := range containers {
dockerCmd(t, "run", "-d", "--name", name, image, "top") dockerCmd(t, "run", "-d", "--name", name, image, "top")

View file

@ -29,7 +29,7 @@ func TestRmiWithContainerFails(t *testing.T) {
} }
// make sure it didn't delete the busybox name // make sure it didn't delete the busybox name
images, _, _ := dockerCmd(t, "images") images, _ := dockerCmd(t, "images")
if !strings.Contains(images, "busybox") { if !strings.Contains(images, "busybox") {
t.Fatalf("The name 'busybox' should not have been removed from images: %q", images) t.Fatalf("The name 'busybox' should not have been removed from images: %q", images)
} }
@ -40,19 +40,19 @@ func TestRmiWithContainerFails(t *testing.T) {
} }
func TestRmiTag(t *testing.T) { func TestRmiTag(t *testing.T) {
imagesBefore, _, _ := dockerCmd(t, "images", "-a") imagesBefore, _ := dockerCmd(t, "images", "-a")
dockerCmd(t, "tag", "busybox", "utest:tag1") dockerCmd(t, "tag", "busybox", "utest:tag1")
dockerCmd(t, "tag", "busybox", "utest/docker:tag2") dockerCmd(t, "tag", "busybox", "utest/docker:tag2")
dockerCmd(t, "tag", "busybox", "utest:5000/docker:tag3") dockerCmd(t, "tag", "busybox", "utest:5000/docker:tag3")
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+3 { if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+3 {
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
} }
} }
dockerCmd(t, "rmi", "utest/docker:tag2") dockerCmd(t, "rmi", "utest/docker:tag2")
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+2 { if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+2 {
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
} }
@ -60,7 +60,7 @@ func TestRmiTag(t *testing.T) {
} }
dockerCmd(t, "rmi", "utest:5000/docker:tag3") dockerCmd(t, "rmi", "utest:5000/docker:tag3")
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+1 { if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+1 {
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
} }
@ -68,7 +68,7 @@ func TestRmiTag(t *testing.T) {
} }
dockerCmd(t, "rmi", "utest:tag1") dockerCmd(t, "rmi", "utest:tag1")
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+0 { if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+0 {
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
} }
@ -90,22 +90,22 @@ func TestRmiImgIDForce(t *testing.T) {
t.Fatalf("failed to commit a new busybox-test:%s, %v", out, err) t.Fatalf("failed to commit a new busybox-test:%s, %v", out, err)
} }
imagesBefore, _, _ := dockerCmd(t, "images", "-a") imagesBefore, _ := dockerCmd(t, "images", "-a")
dockerCmd(t, "tag", "busybox-test", "utest:tag1") dockerCmd(t, "tag", "busybox-test", "utest:tag1")
dockerCmd(t, "tag", "busybox-test", "utest:tag2") dockerCmd(t, "tag", "busybox-test", "utest:tag2")
dockerCmd(t, "tag", "busybox-test", "utest/docker:tag3") dockerCmd(t, "tag", "busybox-test", "utest/docker:tag3")
dockerCmd(t, "tag", "busybox-test", "utest:5000/docker:tag4") dockerCmd(t, "tag", "busybox-test", "utest:5000/docker:tag4")
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+4 { if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+4 {
t.Fatalf("tag busybox to create 4 more images with same imageID; docker images shows: %q\n", imagesAfter) t.Fatalf("tag busybox to create 4 more images with same imageID; docker images shows: %q\n", imagesAfter)
} }
} }
out, _, _ = dockerCmd(t, "inspect", "-f", "{{.Id}}", "busybox-test") out, _ = dockerCmd(t, "inspect", "-f", "{{.Id}}", "busybox-test")
imgID := strings.TrimSpace(out) imgID := strings.TrimSpace(out)
dockerCmd(t, "rmi", "-f", imgID) dockerCmd(t, "rmi", "-f", imgID)
{ {
imagesAfter, _, _ := dockerCmd(t, "images", "-a") imagesAfter, _ := dockerCmd(t, "images", "-a")
if strings.Contains(imagesAfter, imgID[:12]) { if strings.Contains(imagesAfter, imgID[:12]) {
t.Fatalf("rmi -f %s failed, image still exists: %q\n\n", imgID, imagesAfter) t.Fatalf("rmi -f %s failed, image still exists: %q\n\n", imgID, imagesAfter)
} }

View file

@ -501,9 +501,7 @@ func TestRunCreateVolumesInSymlinkDir(t *testing.T) {
} }
defer deleteImages(name) defer deleteImages(name)
if out, _, err := dockerCmd(t, "run", "-v", "/test/test", name); err != nil { dockerCmd(t, "run", "-v", "/test/test", name)
t.Fatal(err, out)
}
logDone("run - create volume in symlink directory") logDone("run - create volume in symlink directory")
} }
@ -1058,9 +1056,9 @@ func TestRunLoopbackWhenNetworkDisabled(t *testing.T) {
func TestRunNetHostNotAllowedWithLinks(t *testing.T) { func TestRunNetHostNotAllowedWithLinks(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
_, _, err := dockerCmd(t, "run", "--name", "linked", "busybox", "true") _, _ = dockerCmd(t, "run", "--name", "linked", "busybox", "true")
cmd := exec.Command(dockerBinary, "run", "--net=host", "--link", "linked:linked", "busybox", "true") cmd := exec.Command(dockerBinary, "run", "--net=host", "--link", "linked:linked", "busybox", "true")
_, _, err = runCommandWithOutput(cmd) _, _, err := runCommandWithOutput(cmd)
if err == nil { if err == nil {
t.Fatal("Expected error") t.Fatal("Expected error")
} }
@ -1493,10 +1491,7 @@ func TestRunModeHostname(t *testing.T) {
func TestRunRootWorkdir(t *testing.T) { func TestRunRootWorkdir(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
s, _, err := dockerCmd(t, "run", "--workdir", "/", "busybox", "pwd") s, _ := dockerCmd(t, "run", "--workdir", "/", "busybox", "pwd")
if err != nil {
t.Fatal(s, err)
}
if s != "/\n" { if s != "/\n" {
t.Fatalf("pwd returned %q (expected /\\n)", s) t.Fatalf("pwd returned %q (expected /\\n)", s)
} }
@ -1507,10 +1502,7 @@ func TestRunRootWorkdir(t *testing.T) {
func TestRunAllowBindMountingRoot(t *testing.T) { func TestRunAllowBindMountingRoot(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
s, _, err := dockerCmd(t, "run", "-v", "/:/host", "busybox", "ls", "/host") _, _ = dockerCmd(t, "run", "-v", "/:/host", "busybox", "ls", "/host")
if err != nil {
t.Fatal(s, err)
}
logDone("run - bind mount / as volume") logDone("run - bind mount / as volume")
} }

View file

@ -157,7 +157,7 @@ func TestStartVolumesFromFailsCleanly(t *testing.T) {
dockerCmd(t, "start", "consumer") dockerCmd(t, "start", "consumer")
// Check that we have the volumes we want // Check that we have the volumes we want
out, _, _ := dockerCmd(t, "inspect", "--format='{{ len .Volumes }}'", "consumer") out, _ := dockerCmd(t, "inspect", "--format='{{ len .Volumes }}'", "consumer")
nVolumes := strings.Trim(out, " \r\n'") nVolumes := strings.Trim(out, " \r\n'")
if nVolumes != "2" { if nVolumes != "2" {
t.Fatalf("Missing volumes: expected 2, got %s", nVolumes) t.Fatalf("Missing volumes: expected 2, got %s", nVolumes)

View file

@ -478,12 +478,12 @@ func pullImageIfNotExist(image string) (err error) {
return return
} }
func dockerCmd(t *testing.T, args ...string) (string, int, error) { func dockerCmd(t *testing.T, args ...string) (string, int) {
out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...)) out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...))
if err != nil { if err != nil {
t.Fatalf("%q failed with errors: %s, %v", strings.Join(args, " "), out, err) t.Fatalf("%q failed with errors: %s, %v", strings.Join(args, " "), out, err)
} }
return out, status, err return out, status
} }
// execute a docker command with a timeout // execute a docker command with a timeout
@ -784,9 +784,9 @@ func getContainerState(t *testing.T, id string) (int, bool, error) {
exitStatus int exitStatus int
running bool running bool
) )
out, exitCode, err := dockerCmd(t, "inspect", "--format={{.State.Running}} {{.State.ExitCode}}", id) out, exitCode := dockerCmd(t, "inspect", "--format={{.State.Running}} {{.State.ExitCode}}", id)
if err != nil || exitCode != 0 { if exitCode != 0 {
return 0, false, fmt.Errorf("%q doesn't exist: %s", id, err) return 0, false, fmt.Errorf("%q doesn't exist: %s", id, out)
} }
out = strings.Trim(out, "\n") out = strings.Trim(out, "\n")