2014-02-25 20:17:48 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2014-09-02 18:35:25 +04:00
|
|
|
"os"
|
2014-02-25 20:17:48 +04:00
|
|
|
"os/exec"
|
2014-07-29 09:50:16 +04:00
|
|
|
"time"
|
2014-09-06 15:49:40 +04:00
|
|
|
|
2015-09-09 16:36:44 +03:00
|
|
|
"github.com/docker/docker/pkg/integration"
|
2016-08-04 19:57:34 +03:00
|
|
|
"github.com/docker/docker/pkg/integration/cmd"
|
2014-02-25 20:17:48 +04:00
|
|
|
)
|
|
|
|
|
2016-02-03 17:16:00 +03:00
|
|
|
func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) {
|
|
|
|
if daemonPlatform == "windows" {
|
|
|
|
return "c:", `\`
|
|
|
|
}
|
|
|
|
return "", "/"
|
|
|
|
}
|
|
|
|
|
2016-08-04 19:57:34 +03:00
|
|
|
// TODO: update code to call cmd.RunCmd directly, and remove this function
|
|
|
|
func runCommandWithOutput(execCmd *exec.Cmd) (string, int, error) {
|
|
|
|
result := cmd.RunCmd(transformCmd(execCmd))
|
|
|
|
return result.Combined(), result.ExitCode, result.Error
|
2014-02-25 20:17:48 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 19:57:34 +03:00
|
|
|
// TODO: update code to call cmd.RunCmd directly, and remove this function
|
|
|
|
func runCommandWithStdoutStderr(execCmd *exec.Cmd) (string, string, int, error) {
|
|
|
|
result := cmd.RunCmd(transformCmd(execCmd))
|
|
|
|
return result.Stdout(), result.Stderr(), result.ExitCode, result.Error
|
2014-08-13 18:23:11 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 19:57:34 +03:00
|
|
|
// TODO: update code to call cmd.RunCmd directly, and remove this function
|
|
|
|
func runCommand(execCmd *exec.Cmd) (exitCode int, err error) {
|
|
|
|
result := cmd.RunCmd(transformCmd(execCmd))
|
|
|
|
return result.ExitCode, result.Error
|
2015-03-11 01:10:00 +03:00
|
|
|
}
|
|
|
|
|
2016-08-04 19:57:34 +03:00
|
|
|
// Temporary shim for migrating commands to the new function
|
|
|
|
func transformCmd(execCmd *exec.Cmd) cmd.Cmd {
|
|
|
|
return cmd.Cmd{
|
|
|
|
Command: execCmd.Args,
|
|
|
|
Env: execCmd.Env,
|
|
|
|
Dir: execCmd.Dir,
|
|
|
|
Stdin: execCmd.Stdin,
|
|
|
|
Stdout: execCmd.Stdout,
|
|
|
|
}
|
2014-02-25 20:17:48 +04:00
|
|
|
}
|
|
|
|
|
2015-02-15 01:25:13 +03:00
|
|
|
func runCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode int, err error) {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.RunCommandPipelineWithOutput(cmds...)
|
2015-02-15 01:25:13 +03:00
|
|
|
}
|
|
|
|
|
2014-07-09 00:25:22 +04:00
|
|
|
func convertSliceOfStringsToMap(input []string) map[string]struct{} {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.ConvertSliceOfStringsToMap(input)
|
2014-07-29 09:50:16 +04:00
|
|
|
}
|
2014-09-02 18:35:25 +04:00
|
|
|
|
|
|
|
func compareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.CompareDirectoryEntries(e1, e2)
|
2014-09-02 18:35:25 +04:00
|
|
|
}
|
2014-09-06 15:49:40 +04:00
|
|
|
|
2015-07-22 15:59:24 +03:00
|
|
|
func listTar(f io.Reader) ([]string, error) {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.ListTar(f)
|
2014-09-06 15:49:40 +04:00
|
|
|
}
|
2014-09-12 21:10:42 +04:00
|
|
|
|
2015-09-24 20:53:47 +03:00
|
|
|
func randomTmpDirPath(s string, platform string) string {
|
|
|
|
return integration.RandomTmpDirPath(s, platform)
|
2015-02-14 09:59:01 +03:00
|
|
|
}
|
|
|
|
|
2014-10-30 22:10:38 +03:00
|
|
|
func consumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.ConsumeWithSpeed(reader, chunkSize, interval, stop)
|
2014-10-30 21:52:13 +03:00
|
|
|
}
|
2015-03-21 01:32:40 +03:00
|
|
|
|
|
|
|
func parseCgroupPaths(procCgroupData string) map[string]string {
|
2015-09-09 16:36:44 +03:00
|
|
|
return integration.ParseCgroupPaths(procCgroupData)
|
2015-05-27 05:22:03 +03:00
|
|
|
}
|
2015-07-22 19:14:48 +03:00
|
|
|
|
|
|
|
func runAtDifferentDate(date time.Time, block func()) {
|
2015-09-09 16:36:44 +03:00
|
|
|
integration.RunAtDifferentDate(date, block)
|
2015-07-22 19:14:48 +03:00
|
|
|
}
|