2018-02-05 21:05:59 +00:00
|
|
|
package volume // import "github.com/docker/docker/volume"
|
2015-05-19 20:05:25 +00:00
|
|
|
|
2015-09-10 02:23:06 +00:00
|
|
|
import (
|
2023-06-14 19:20:23 +00:00
|
|
|
"context"
|
2017-05-17 21:19:13 +00:00
|
|
|
"time"
|
2015-09-10 02:23:06 +00:00
|
|
|
)
|
|
|
|
|
2015-07-21 17:50:10 +00:00
|
|
|
// DefaultDriverName is the driver name used for the driver
|
|
|
|
// implemented in the local package.
|
2016-04-11 15:17:52 +00: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 20:05:25 +00:00
|
|
|
|
2015-07-21 17:50:10 +00:00
|
|
|
// Driver is for creating and removing volumes.
|
2015-05-19 20:05:25 +00:00
|
|
|
type Driver interface {
|
|
|
|
// Name returns the name of the volume driver.
|
|
|
|
Name() string
|
2017-01-04 20:06:37 +00:00
|
|
|
// Create makes a new volume with the given name.
|
2015-06-12 13:25:32 +00:00
|
|
|
Create(name string, opts map[string]string) (Volume, error)
|
2015-05-19 20:05:25 +00:00
|
|
|
// Remove deletes the volume.
|
2015-09-23 20:29:14 +00:00
|
|
|
Remove(vol Volume) (err error)
|
|
|
|
// List lists all the volumes the driver has
|
|
|
|
List() ([]Volume, error)
|
2016-02-11 23:21:52 +00:00
|
|
|
// Get retrieves the volume with the requested name
|
2015-09-23 20:29:14 +00:00
|
|
|
Get(name string) (Volume, error)
|
2016-07-01 21:29:08 +00:00
|
|
|
// Scope returns the scope of the driver (e.g. `global` or `local`).
|
2016-04-11 15:17:52 +00: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 20:05:25 +00:00
|
|
|
}
|
|
|
|
|
2015-07-21 17:50:10 +00:00
|
|
|
// Volume is a place to store data. It is backed by a specific driver, and can be mounted.
|
2015-05-19 20:05:25 +00: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-08 02:41:44 +00:00
|
|
|
Mount(id string) (string, error)
|
2015-05-19 20:05:25 +00:00
|
|
|
// Unmount unmounts the volume when it is no longer in use.
|
2016-03-08 02:41:44 +00:00
|
|
|
Unmount(id string) error
|
2017-05-17 21:19:13 +00:00
|
|
|
// CreatedAt returns Volume Creation time
|
|
|
|
CreatedAt() (time.Time, error)
|
2016-03-07 20:44:43 +00:00
|
|
|
// Status returns low-level status information about a volume
|
|
|
|
Status() map[string]interface{}
|
2015-05-19 20:05:25 +00:00
|
|
|
}
|
2015-07-12 08:33:30 +00:00
|
|
|
|
2023-06-14 19:20:23 +00:00
|
|
|
// LiveRestorer is an optional interface that can be implemented by a volume driver
|
|
|
|
// It is used to restore any resources that are necessary for a volume to be used by a live-restored container
|
|
|
|
type LiveRestorer interface {
|
|
|
|
// LiveRestoreVolume allows a volume driver which implements this interface to restore any necessary resources (such as reference counting)
|
|
|
|
// This is called only after the daemon is restarted with live-restored containers
|
|
|
|
// It is called once per live-restored container.
|
|
|
|
LiveRestoreVolume(_ context.Context, ref string) error
|
|
|
|
}
|
|
|
|
|
2016-09-17 19:32:31 +00:00
|
|
|
// DetailedVolume wraps a Volume with user-defined labels, options, and cluster scope (e.g., `local` or `global`)
|
|
|
|
type DetailedVolume interface {
|
2016-04-11 15:17:52 +00:00
|
|
|
Labels() map[string]string
|
2016-09-17 19:32:31 +00:00
|
|
|
Options() map[string]string
|
2016-04-11 15:17:52 +00:00
|
|
|
Scope() string
|
|
|
|
Volume
|
|
|
|
}
|