mirror of
https://github.com/moby/moby.git
synced 2026-07-12 10:35:14 +00:00
We don't yet support this at the API level, so for now it returns an error when trying to set multiple, but this makes sure that the client types are already ready for this. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
35 lines
818 B
Go
35 lines
818 B
Go
package client // import "github.com/docker/docker/client"
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types/image"
|
|
)
|
|
|
|
// ImageSave retrieves one or more images from the docker host as an io.ReadCloser.
|
|
// It's up to the caller to store the images and close the stream.
|
|
func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, opts image.SaveOptions) (io.ReadCloser, error) {
|
|
query := url.Values{
|
|
"names": imageIDs,
|
|
}
|
|
|
|
if len(opts.Platforms) > 0 {
|
|
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
|
return nil, err
|
|
}
|
|
p, err := encodePlatforms(opts.Platforms...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
query["platform"] = p
|
|
}
|
|
|
|
resp, err := cli.get(ctx, "/images/get", query, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return resp.body, nil
|
|
}
|