2015-05-19 16:05:25 -04:00
|
|
|
package volume
|
|
|
|
|
2015-07-21 13:50:10 -04:00
|
|
|
// DefaultDriverName is the driver name used for the driver
|
|
|
|
// implemented in the local package.
|
|
|
|
const DefaultDriverName string = "local"
|
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
|
|
|
|
// Create makes a new volume with the given id.
|
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.
|
|
|
|
Remove(Volume) error
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
Mount() (string, error)
|
|
|
|
// Unmount unmounts the volume when it is no longer in use.
|
|
|
|
Unmount() error
|
|
|
|
}
|
2015-07-12 04:33:30 -04:00
|
|
|
|
|
|
|
// read-write modes
|
|
|
|
var rwModes = map[string]bool{
|
|
|
|
"rw": true,
|
|
|
|
"rw,Z": true,
|
|
|
|
"rw,z": true,
|
|
|
|
"z,rw": true,
|
|
|
|
"Z,rw": true,
|
|
|
|
"Z": true,
|
|
|
|
"z": true,
|
|
|
|
}
|
|
|
|
|
|
|
|
// read-only modes
|
|
|
|
var roModes = map[string]bool{
|
|
|
|
"ro": true,
|
|
|
|
"ro,Z": true,
|
|
|
|
"ro,z": true,
|
|
|
|
"z,ro": true,
|
|
|
|
"Z,ro": true,
|
|
|
|
}
|
|
|
|
|
2015-08-24 05:28:19 -04:00
|
|
|
// ValidMountMode will make sure the mount mode is valid.
|
|
|
|
// returns if it's a valid mount mode or not.
|
|
|
|
func ValidMountMode(mode string) bool {
|
|
|
|
return roModes[mode] || rwModes[mode]
|
2015-07-12 04:33:30 -04:00
|
|
|
}
|
2015-07-14 18:49:18 -04:00
|
|
|
|
2015-08-24 05:28:19 -04:00
|
|
|
// ReadWrite tells you if a mode string is a valid read-write mode or not.
|
2015-07-14 18:49:18 -04:00
|
|
|
func ReadWrite(mode string) bool {
|
|
|
|
return rwModes[mode]
|
|
|
|
}
|