client: support multiple platforms on save and load

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>
This commit is contained in:
Sebastiaan van Stijn
2024-10-28 18:03:54 +01:00
parent 84ad184fe5
commit 9c9eccfb23
7 changed files with 73 additions and 16 deletions

View File

@@ -15,16 +15,15 @@ func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, opts image.
"names": imageIDs,
}
if opts.Platform != nil {
if len(opts.Platforms) > 0 {
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
return nil, err
}
p, err := encodePlatform(opts.Platform)
p, err := encodePlatforms(opts.Platforms...)
if err != nil {
return nil, err
}
query.Set("platform", p)
query["platform"] = p
}
resp, err := cli.get(ctx, "/images/get", query, nil)