mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
For methods using the decodeWithRaw utility, we were handling closing of the body twice. The ensureReaderClosed utility also drains the response to let the transport reuse the connnection. Let's use that utility in decodeWithRaw as well. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
37 lines
934 B
Go
37 lines
934 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/moby/moby/api/types/volume"
|
|
)
|
|
|
|
// VolumeInspectOptions holds options for inspecting a volume.
|
|
type VolumeInspectOptions struct {
|
|
// Add future optional parameters here
|
|
}
|
|
|
|
// VolumeInspectResult holds the result from the [Client.VolumeInspect] method.
|
|
type VolumeInspectResult struct {
|
|
Volume volume.Volume
|
|
Raw json.RawMessage
|
|
}
|
|
|
|
// VolumeInspect returns the information about a specific volume in the docker host.
|
|
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error) {
|
|
volumeID, err := trimID("volume", volumeID)
|
|
if err != nil {
|
|
return VolumeInspectResult{}, err
|
|
}
|
|
|
|
resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
|
|
if err != nil {
|
|
return VolumeInspectResult{}, err
|
|
}
|
|
|
|
var out VolumeInspectResult
|
|
out.Raw, err = decodeWithRaw(resp, &out.Volume)
|
|
return out, err
|
|
}
|