2016-09-06 18:46:37 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2016-10-14 20:20:13 +00:00
|
|
|
volumetypes "github.com/docker/docker/api/types/volume"
|
2016-09-06 18:46:37 +00:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VolumeCreate creates a volume in the docker host.
|
2016-10-06 16:57:17 +00:00
|
|
|
func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) {
|
2016-09-06 18:46:37 +00:00
|
|
|
var volume types.Volume
|
|
|
|
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
|
|
|
|
if err != nil {
|
|
|
|
return volume, err
|
|
|
|
}
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&volume)
|
|
|
|
ensureReaderClosed(resp)
|
|
|
|
return volume, err
|
|
|
|
}
|