github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/volume/volume.go (about) 1 package volume // import "github.com/docker/docker/volume" 2 3 import ( 4 "time" 5 ) 6 7 // DefaultDriverName is the driver name used for the driver 8 // implemented in the local package. 9 const DefaultDriverName = "local" 10 11 // Scopes define if a volume has is cluster-wide (global) or local only. 12 // Scopes are returned by the volume driver when it is queried for capabilities and then set on a volume 13 const ( 14 LocalScope = "local" 15 GlobalScope = "global" 16 ) 17 18 // Driver is for creating and removing volumes. 19 type Driver interface { 20 // Name returns the name of the volume driver. 21 Name() string 22 // Create makes a new volume with the given name. 23 Create(name string, opts map[string]string) (Volume, error) 24 // Remove deletes the volume. 25 Remove(vol Volume) (err error) 26 // List lists all the volumes the driver has 27 List() ([]Volume, error) 28 // Get retrieves the volume with the requested name 29 Get(name string) (Volume, error) 30 // Scope returns the scope of the driver (e.g. `global` or `local`). 31 // Scope determines how the driver is handled at a cluster level 32 Scope() string 33 } 34 35 // Capability defines a set of capabilities that a driver is able to handle. 36 type Capability struct { 37 // Scope is the scope of the driver, `global` or `local` 38 // A `global` scope indicates that the driver manages volumes across the cluster 39 // A `local` scope indicates that the driver only manages volumes resources local to the host 40 // Scope is declared by the driver 41 Scope string 42 } 43 44 // Volume is a place to store data. It is backed by a specific driver, and can be mounted. 45 type Volume interface { 46 // Name returns the name of the volume 47 Name() string 48 // DriverName returns the name of the driver which owns this volume. 49 DriverName() string 50 // Path returns the absolute path to the volume. 51 Path() string 52 // Mount mounts the volume and returns the absolute path to 53 // where it can be consumed. 54 Mount(id string) (string, error) 55 // Unmount unmounts the volume when it is no longer in use. 56 Unmount(id string) error 57 // CreatedAt returns Volume Creation time 58 CreatedAt() (time.Time, error) 59 // Status returns low-level status information about a volume 60 Status() map[string]interface{} 61 } 62 63 // DetailedVolume wraps a Volume with user-defined labels, options, and cluster scope (e.g., `local` or `global`) 64 type DetailedVolume interface { 65 Labels() map[string]string 66 Options() map[string]string 67 Scope() string 68 Volume 69 }