зеркало из https://github.com/docker/engine-api.git
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:
Коммит
1c4dcce1c9
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче