2018-02-05 16:05:59 -05:00
|
|
|
package volume // import "github.com/docker/docker/volume"
|
2015-05-19 16:05:25 -04:00
|
|
|
|
2015-09-09 22:23:06 -04:00
|
|
|
import (
|
2017-05-17 17:19:13 -04:00
|
|
|
"time"
|
2015-09-09 22:23:06 -04:00
|
|
|
)
|
|
|
|
|
2015-07-21 13:50:10 -04:00
|
|
|
// DefaultDriverName is the driver name used for the driver
|
|
|
|
// implemented in the local package.
|
2016-04-11 11:17:52 -04:00
|
|
|
const DefaultDriverName = "local"
|
|
|
|
|
|
|
|
// Scopes define if a volume has is cluster-wide (global) or local only.
|
|
|
|
// Scopes are returned by the volume driver when it is queried for capabilities and then set on a volume
|
|
|
|
const (
|
|
|
|
LocalScope = "local"
|
|
|
|
GlobalScope = "global"
|
|
|
|
)
|
2015-05-19 16:05:25 -04:00
|
|
|
|
2015-07-21 13:50:10 -04:00
|
|
|
// Driver is for creating and removing volumes.
|
2015-05-19 16:05:25 -04:00
|
|
|
type Driver interface {
|
|
|
|
// Name returns the name of the volume driver.
|
|
|
|
Name() string
|
2017-01-04 15:06:37 -05:00
|
|
|
// Create makes a new volume with the given name.
|
2015-06-12 09:25:32 -04:00
|
|
|
Create(name string, opts map[string]string) (Volume, error)
|
2015-05-19 16:05:25 -04:00
|
|
|
// Remove deletes the volume.
|
2015-09-23 16:29:14 -04:00
|
|
|
Remove(vol Volume) (err error)
|
|
|
|
// List lists all the volumes the driver has
|
|
|
|
List() ([]Volume, error)
|
2016-02-11 18:21:52 -05:00
|
|
|
// Get retrieves the volume with the requested name
|
2015-09-23 16:29:14 -04:00
|
|
|
Get(name string) (Volume, error)
|
2016-07-01 17:29:08 -04:00
|
|
|
// Scope returns the scope of the driver (e.g. `global` or `local`).
|
2016-04-11 11:17:52 -04:00
|
|
|
// Scope determines how the driver is handled at a cluster level
|
|
|
|
Scope() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Capability defines a set of capabilities that a driver is able to handle.
|
|
|
|
type Capability struct {
|
|
|
|
// Scope is the scope of the driver, `global` or `local`
|
|
|
|
// A `global` scope indicates that the driver manages volumes across the cluster
|
|
|
|
// A `local` scope indicates that the driver only manages volumes resources local to the host
|
|
|
|
// Scope is declared by the driver
|
|
|
|
Scope string
|
2015-05-19 16:05:25 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 13:50:10 -04:00
|
|
|
// Volume is a place to store data. It is backed by a specific driver, and can be mounted.
|
2015-05-19 16:05:25 -04:00
|
|
|
type Volume interface {
|
|
|
|
// Name returns the name of the volume
|
|
|
|
Name() string
|
|
|
|
// DriverName returns the name of the driver which owns this volume.
|
|
|
|
DriverName() string
|
|
|
|
// Path returns the absolute path to the volume.
|
|
|
|
Path() string
|
|
|
|
// Mount mounts the volume and returns the absolute path to
|
|
|
|
// where it can be consumed.
|
2016-03-07 21:41:44 -05:00
|
|
|
Mount(id string) (string, error)
|
2015-05-19 16:05:25 -04:00
|
|
|
// Unmount unmounts the volume when it is no longer in use.
|
2016-03-07 21:41:44 -05:00
|
|
|
Unmount(id string) error
|
2017-05-17 17:19:13 -04:00
|
|
|
// CreatedAt returns Volume Creation time
|
|
|
|
CreatedAt() (time.Time, error)
|
2016-03-07 15:44:43 -05:00
|
|
|
// Status returns low-level status information about a volume
|
|
|
|
Status() map[string]interface{}
|
2015-05-19 16:05:25 -04:00
|
|
|
}
|
2015-07-12 04:33:30 -04:00
|
|
|
|
2016-09-17 15:32:31 -04:00
|
|
|
// DetailedVolume wraps a Volume with user-defined labels, options, and cluster scope (e.g., `local` or `global`)
|
|
|
|
type DetailedVolume interface {
|
2016-04-11 11:17:52 -04:00
|
|
|
Labels() map[string]string
|
2016-09-17 15:32:31 -04:00
|
|
|
Options() map[string]string
|
2016-04-11 11:17:52 -04:00
|
|
|
Scope() string
|
|
|
|
Volume
|
|
|
|
}
|