github.com/tompao/docker@v1.9.1/volume/volume.go (about) 1 package volume 2 3 // DefaultDriverName is the driver name used for the driver 4 // implemented in the local package. 5 const DefaultDriverName string = "local" 6 7 // Driver is for creating and removing volumes. 8 type Driver interface { 9 // Name returns the name of the volume driver. 10 Name() string 11 // Create makes a new volume with the given id. 12 Create(name string, opts map[string]string) (Volume, error) 13 // Remove deletes the volume. 14 Remove(Volume) error 15 } 16 17 // Volume is a place to store data. It is backed by a specific driver, and can be mounted. 18 type Volume interface { 19 // Name returns the name of the volume 20 Name() string 21 // DriverName returns the name of the driver which owns this volume. 22 DriverName() string 23 // Path returns the absolute path to the volume. 24 Path() string 25 // Mount mounts the volume and returns the absolute path to 26 // where it can be consumed. 27 Mount() (string, error) 28 // Unmount unmounts the volume when it is no longer in use. 29 Unmount() error 30 } 31 32 // read-write modes 33 var rwModes = map[string]bool{ 34 "rw": true, 35 "rw,Z": true, 36 "rw,z": true, 37 "z,rw": true, 38 "Z,rw": true, 39 "Z": true, 40 "z": true, 41 } 42 43 // read-only modes 44 var roModes = map[string]bool{ 45 "ro": true, 46 "ro,Z": true, 47 "ro,z": true, 48 "z,ro": true, 49 "Z,ro": true, 50 } 51 52 // ValidMountMode will make sure the mount mode is valid. 53 // returns if it's a valid mount mode or not. 54 func ValidMountMode(mode string) bool { 55 return roModes[mode] || rwModes[mode] 56 } 57 58 // ReadWrite tells you if a mode string is a valid read-write mode or not. 59 func ReadWrite(mode string) bool { 60 return rwModes[mode] 61 }