mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-04 15:58:39 +00:00
Merge pull request #16261 from vdemeester/integration-dockercmd
Move dockerCmd to pkg/integration and add tests to it
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/docker/docker/pkg/httputils"
|
||||
"github.com/docker/docker/pkg/integration"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/stringutils"
|
||||
"github.com/go-check/check"
|
||||
@@ -621,52 +622,30 @@ func pullImageIfNotExist(image string) (err error) {
|
||||
}
|
||||
|
||||
func dockerCmdWithError(args ...string) (string, int, error) {
|
||||
return runCommandWithOutput(exec.Command(dockerBinary, args...))
|
||||
return integration.DockerCmdWithError(dockerBinary, args...)
|
||||
}
|
||||
|
||||
func dockerCmdWithStdoutStderr(c *check.C, args ...string) (string, string, int) {
|
||||
stdout, stderr, status, err := runCommandWithStdoutStderr(exec.Command(dockerBinary, args...))
|
||||
if c != nil {
|
||||
c.Assert(err, check.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(args, " "), stderr, err))
|
||||
}
|
||||
return stdout, stderr, status
|
||||
return integration.DockerCmdWithStdoutStderr(dockerBinary, c, args...)
|
||||
}
|
||||
|
||||
func dockerCmd(c *check.C, args ...string) (string, int) {
|
||||
out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...))
|
||||
c.Assert(err, check.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(args, " "), out, err))
|
||||
return out, status
|
||||
return integration.DockerCmd(dockerBinary, c, args...)
|
||||
}
|
||||
|
||||
// execute a docker command with a timeout
|
||||
func dockerCmdWithTimeout(timeout time.Duration, args ...string) (string, int, error) {
|
||||
out, status, err := runCommandWithOutputAndTimeout(exec.Command(dockerBinary, args...), timeout)
|
||||
if err != nil {
|
||||
return out, status, fmt.Errorf("%q failed with errors: %v : %q)", strings.Join(args, " "), err, out)
|
||||
}
|
||||
return out, status, err
|
||||
return integration.DockerCmdWithTimeout(dockerBinary, timeout, args...)
|
||||
}
|
||||
|
||||
// execute a docker command in a directory
|
||||
func dockerCmdInDir(c *check.C, path string, args ...string) (string, int, error) {
|
||||
dockerCommand := exec.Command(dockerBinary, args...)
|
||||
dockerCommand.Dir = path
|
||||
out, status, err := runCommandWithOutput(dockerCommand)
|
||||
if err != nil {
|
||||
return out, status, fmt.Errorf("%q failed with errors: %v : %q)", strings.Join(args, " "), err, out)
|
||||
}
|
||||
return out, status, err
|
||||
return integration.DockerCmdInDir(dockerBinary, path, args...)
|
||||
}
|
||||
|
||||
// execute a docker command in a directory with a timeout
|
||||
func dockerCmdInDirWithTimeout(timeout time.Duration, path string, args ...string) (string, int, error) {
|
||||
dockerCommand := exec.Command(dockerBinary, args...)
|
||||
dockerCommand.Dir = path
|
||||
out, status, err := runCommandWithOutputAndTimeout(dockerCommand, timeout)
|
||||
if err != nil {
|
||||
return out, status, fmt.Errorf("%q failed with errors: %v : %q)", strings.Join(args, " "), err, out)
|
||||
}
|
||||
return out, status, err
|
||||
return integration.DockerCmdInDirWithTimeout(dockerBinary, timeout, path, args...)
|
||||
}
|
||||
|
||||
func findContainerIP(c *check.C, id string, vargs ...string) string {
|
||||
|
||||
Reference in New Issue
Block a user