github.com/toophy/docker@v1.8.2/volume/volume.go (about)

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