mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client/image_(inspect,history,load,save): Wrap return values
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
7066eb3736
commit
2d69edd28a
@@ -2,21 +2,20 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// ImageSave retrieves one or more images from the docker host as an
|
||||
// [io.ReadCloser].
|
||||
// [ImageSaveResult].
|
||||
//
|
||||
// Platforms is an optional parameter that specifies the platforms to save
|
||||
// from the image. Passing a platform only has an effect if the input image
|
||||
// is a multi-platform image.
|
||||
func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (io.ReadCloser, error) {
|
||||
func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (ImageSaveResult, error) {
|
||||
var opts imageSaveOpts
|
||||
for _, opt := range saveOpts {
|
||||
if err := opt.Apply(&opts); err != nil {
|
||||
return nil, err
|
||||
return ImageSaveResult{}, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,18 +25,18 @@ func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ..
|
||||
|
||||
if len(opts.apiOptions.Platforms) > 0 {
|
||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
||||
return nil, err
|
||||
return ImageSaveResult{}, err
|
||||
}
|
||||
p, err := encodePlatforms(opts.apiOptions.Platforms...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return ImageSaveResult{}, err
|
||||
}
|
||||
query["platform"] = p
|
||||
}
|
||||
|
||||
resp, err := cli.get(ctx, "/images/get", query, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return ImageSaveResult{}, err
|
||||
}
|
||||
return resp.Body, nil
|
||||
return newImageSaveResult(resp.Body), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user