Removed engine from /copy

* Client and server use types.CopyConfig
* API calls container.Copy directly

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov
2015-04-09 13:05:31 -07:00
parent 6fb8bd0450
commit ccdef895de
5 changed files with 37 additions and 59 deletions
+8 -10
View File
@@ -5,7 +5,7 @@ import (
"io"
"strings"
"github.com/docker/docker/engine"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/archive"
flag "github.com/docker/docker/pkg/mflag"
)
@@ -21,17 +21,16 @@ func (cli *DockerCli) CmdCp(args ...string) error {
cmd.ParseFlags(args, true)
var copyData engine.Env
info := strings.Split(cmd.Arg(0), ":")
if len(info) != 2 {
return fmt.Errorf("Error: Path not specified")
}
copyData.Set("Resource", info[1])
copyData.Set("HostPath", cmd.Arg(1))
stream, statusCode, err := cli.call("POST", "/containers/"+info[0]+"/copy", copyData, nil)
cfg := &types.CopyConfig{
Resource: info[1],
}
stream, statusCode, err := cli.call("POST", "/containers/"+info[0]+"/copy", cfg, nil)
if stream != nil {
defer stream.Close()
}
@@ -42,13 +41,12 @@ func (cli *DockerCli) CmdCp(args ...string) error {
return err
}
hostPath := cmd.Arg(1)
if statusCode == 200 {
dest := copyData.Get("HostPath")
if dest == "-" {
if hostPath == "-" {
_, err = io.Copy(cli.out, stream)
} else {
err = archive.Untar(stream, dest, &archive.TarOptions{NoLchown: true})
err = archive.Untar(stream, hostPath, &archive.TarOptions{NoLchown: true})
}
if err != nil {
return err