Merge pull request #18878 from calavera/conditional_load_response

Make `docker load` to output json when the response content type is json.
This commit is contained in:
Antonio Murdaca 2015-12-24 01:11:54 +01:00
Родитель 78958e5c8d fc0f6a4e28
Коммит 1c4dcce1c9
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -3,15 +3,20 @@ package lib
import (
"io"
"net/url"
"github.com/docker/docker/api/types"
)
// ImageLoad loads an image in the docker host from the client host.
// It's up to the caller to close the io.ReadCloser returned by
// this function.
func (cli *Client) ImageLoad(input io.Reader) (io.ReadCloser, error) {
func (cli *Client) ImageLoad(input io.Reader) (types.ImageLoadResponse, error) {
resp, err := cli.postRaw("/images/load", url.Values{}, input, nil)
if err != nil {
return nil, err
return types.ImageLoadResponse{}, err
}
return resp.body, nil
return types.ImageLoadResponse{
Body: resp.body,
JSON: resp.header.Get("Content-Type") == "application/json",
}, nil
}

Просмотреть файл

@ -184,6 +184,12 @@ type ImageListOptions struct {
Filters filters.Args
}
// ImageLoadResponse returns information to the client about a load process.
type ImageLoadResponse struct {
Body io.ReadCloser
JSON bool
}
// ImagePullOptions holds information to pull images.
type ImagePullOptions struct {
ImageID string