client: Client.ImageHistory: don't decorate error twice

I forgot to include this patch in 96039276b6,
which introduced the encodePlatform, which already decorates the error to
have a `invalid platform:` prefix.

While updating, also be more explicit on no result being returned on error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-11-05 12:54:49 +01:00
parent 47a6de71c2
commit 5cfd326aa4

View File

@@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client"
import (
"context"
"encoding/json"
"fmt"
"net/url"
"github.com/docker/docker/api/types/image"
@@ -19,18 +18,18 @@ func (cli *Client) ImageHistory(ctx context.Context, imageID string, opts image.
p, err := encodePlatform(opts.Platform)
if err != nil {
return nil, fmt.Errorf("invalid platform: %v", err)
return nil, err
}
query.Set("platform", p)
}
var history []image.HistoryResponseItem
serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", query, nil)
defer ensureReaderClosed(serverResp)
if err != nil {
return history, err
return nil, err
}
var history []image.HistoryResponseItem
err = json.NewDecoder(serverResp.body).Decode(&history)
return history, err
}