|
@@ -23,7 +23,7 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri
|
|
|
urlStr := "/containers/" + containerID + "/archive"
|
|
|
response, err := cli.head(ctx, urlStr, query, nil)
|
|
|
if err != nil {
|
|
|
- return types.ContainerPathStat{}, err
|
|
|
+ return types.ContainerPathStat{}, wrapResponseError(err, response, "container:path", containerID+":"+path)
|
|
|
}
|
|
|
defer ensureReaderClosed(response)
|
|
|
return getContainerPathStatFromHeader(response.header)
|
|
@@ -31,9 +31,9 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri
|
|
|
|
|
|
// CopyToContainer copies content into the container filesystem.
|
|
|
// Note that `content` must be a Reader for a TAR archive
|
|
|
-func (cli *Client) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error {
|
|
|
+func (cli *Client) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options types.CopyToContainerOptions) error {
|
|
|
query := url.Values{}
|
|
|
- query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
|
|
|
+ query.Set("path", filepath.ToSlash(dstPath)) // Normalize the paths used in the API.
|
|
|
// Do not allow for an existing directory to be overwritten by a non-directory and vice versa.
|
|
|
if !options.AllowOverwriteDirWithFile {
|
|
|
query.Set("noOverwriteDirNonDir", "true")
|
|
@@ -43,11 +43,11 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string,
|
|
|
query.Set("copyUIDGID", "true")
|
|
|
}
|
|
|
|
|
|
- apiPath := "/containers/" + container + "/archive"
|
|
|
+ apiPath := "/containers/" + containerID + "/archive"
|
|
|
|
|
|
response, err := cli.putRaw(ctx, apiPath, query, content, nil)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return wrapResponseError(err, response, "container:path", containerID+":"+dstPath)
|
|
|
}
|
|
|
defer ensureReaderClosed(response)
|
|
|
|
|
@@ -60,14 +60,14 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string,
|
|
|
|
|
|
// CopyFromContainer gets the content from the container and returns it as a Reader
|
|
|
// for a TAR archive to manipulate it in the host. It's up to the caller to close the reader.
|
|
|
-func (cli *Client) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
|
|
|
+func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
|
|
|
query := make(url.Values, 1)
|
|
|
query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
|
|
|
|
|
|
- apiPath := "/containers/" + container + "/archive"
|
|
|
+ apiPath := "/containers/" + containerID + "/archive"
|
|
|
response, err := cli.get(ctx, apiPath, query, nil)
|
|
|
if err != nil {
|
|
|
- return nil, types.ContainerPathStat{}, err
|
|
|
+ return nil, types.ContainerPathStat{}, wrapResponseError(err, response, "container:path", containerID+":"+srcPath)
|
|
|
}
|
|
|
|
|
|
if response.statusCode != http.StatusOK {
|