also needs to update docker/docker to a60b458 (22.06 branch) otherwise build breaks since docker/cli#3512 with: # github.com/docker/cli/cli/flags vendor/github.com/docker/cli/cli/flags/common.go:40:37: undefined: client.EnvOverrideCertPath vendor/github.com/docker/cli/cli/flags/common.go:41:37: undefined: client.EnvTLSVerify vendor/github.com/docker/cli/cli/flags/common.go:89:76: undefined: client.EnvOverrideHost needs also to update github.com/spf13/cobra to v1.5.0 otherwise build breaks with: # github.com/docker/cli/cli-plugins/plugin vendor/github.com/docker/cli/cli-plugins/plugin/plugin.go:130:4: unknown field 'HiddenDefaultCmd' in struct literal of type cobra.CompletionOptions Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package client // import "github.com/docker/docker/client"
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"io"
|
|
|
|
"github.com/docker/docker/api/types/volume"
|
|
)
|
|
|
|
// VolumeInspect returns the information about a specific volume in the docker host.
|
|
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) {
|
|
vol, _, err := cli.VolumeInspectWithRaw(ctx, volumeID)
|
|
return vol, err
|
|
}
|
|
|
|
// VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation
|
|
func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) {
|
|
if volumeID == "" {
|
|
return volume.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}
|
|
}
|
|
|
|
var vol volume.Volume
|
|
resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return vol, nil, err
|
|
}
|
|
|
|
body, err := io.ReadAll(resp.body)
|
|
if err != nil {
|
|
return vol, nil, err
|
|
}
|
|
rdr := bytes.NewReader(body)
|
|
err = json.NewDecoder(rdr).Decode(&vol)
|
|
return vol, body, err
|
|
}
|