Documentation ¶
Index ¶
- Constants
- func GetPropagation(mode string) string
- func HasPropagation(mode string) bool
- func IsVolumeNameValid(name string) (bool, error)
- func ParseVolumeSource(spec string) (string, string)
- func ParseVolumesFrom(spec string) (string, string, error)
- func ReadWrite(mode string) bool
- func ValidMountMode(mode string) bool
- type Capability
- type Driver
- type LabeledVolume
- type MountPoint
- type ScopedVolume
- type Volume
Constants ¶
const ( LocalScope = "local" GlobalScope = "global" )
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 ( // DefaultCopyMode is the copy mode used by default for normal/named volumes DefaultCopyMode = true )
const DefaultDriverName = "local"
DefaultDriverName is the driver name used for the driver implemented in the local package.
const DefaultPropagationMode string = "rprivate"
DefaultPropagationMode defines what propagation mode should be used by default if user has not specified one explicitly.
Variables ¶
This section is empty.
Functions ¶
func GetPropagation ¶ added in v1.10.0
GetPropagation extracts and returns the mount propagation mode. If there are no specifications, then by default it is "private".
func HasPropagation ¶ added in v1.10.0
HasPropagation checks if there is a valid propagation mode present in passed string. Returns true if a valid propagation mode specifier is present, false otherwise.
func IsVolumeNameValid ¶ added in v1.10.0
IsVolumeNameValid checks a volume name in a platform specific manner.
func ParseVolumeSource ¶ added in v1.10.0
ParseVolumeSource parses the origin sources that's mounted into the container. It returns a name and a source. It looks to see if the spec passed in is an absolute file. If it is, it assumes the spec is a source. If not, it assumes the spec is a name.
func ParseVolumesFrom ¶ added in v1.10.0
ParseVolumesFrom ensures that the supplied volumes-from is valid.
func ReadWrite ¶ added in v1.8.0
ReadWrite tells you if a mode string is a valid read-write mode or not. If there are no specifications w.r.t read write mode, then by default it returns true.
func ValidMountMode ¶ added in v1.9.0
ValidMountMode will make sure the mount mode is valid. returns if it's a valid mount mode or not.
Types ¶
type Capability ¶ added in v1.12.0
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 }
Capability defines a set of capabilities that a driver is able to handle.
type Driver ¶
type Driver interface { // Name returns the name of the volume driver. Name() string // Create makes a new volume with the given id. Create(name string, opts map[string]string) (Volume, error) // Remove deletes the volume. Remove(vol Volume) (err error) // List lists all the volumes the driver has List() ([]Volume, error) // Get retrieves the volume with the requested name Get(name string) (Volume, error) // Scope returns the scope of the driver (e.g. `golbal` or `local`). // Scope determines how the driver is handled at a cluster level Scope() string }
Driver is for creating and removing volumes.
type LabeledVolume ¶ added in v1.12.0
LabeledVolume wraps a Volume with user-defined labels
type MountPoint ¶ added in v1.10.0
type MountPoint struct { Source string // Container host directory Destination string // Inside the container RW bool // True if writable Name string // Name set by user Driver string // Volume driver to use Volume Volume `json:"-"` // Note Mode is not used on Windows Mode string `json:"Relabel"` // Originally field was `Relabel`" // Note Propagation is not used on Windows Propagation string // Mount propagation string Named bool // specifies if the mountpoint was specified by name // Specifies if data should be copied from the container before the first mount // Use a pointer here so we can tell if the user set this value explicitly // This allows us to error out when the user explicitly enabled copy but we can't copy due to the volume being populated CopyData bool `json:"-"` // ID is the opaque ID used to pass to the volume driver. // This should be set by calls to `Mount` and unset by calls to `Unmount` ID string }
MountPoint is the intersection point between a volume and a container. It specifies which volume is to be used and where inside a container it should be mounted.
func ParseMountSpec ¶ added in v1.10.0
func ParseMountSpec(spec, volumeDriver string) (*MountPoint, error)
ParseMountSpec validates the configuration of mount information is valid.
func (*MountPoint) BackwardsCompatible ¶ added in v1.10.0
func (m *MountPoint) BackwardsCompatible() bool
BackwardsCompatible decides whether this mount point can be used in old versions of Docker or not. Only bind mounts and local volumes can be used in old versions of Docker.
func (*MountPoint) HasResource ¶ added in v1.10.0
func (m *MountPoint) HasResource(absolutePath string) bool
HasResource checks whether the given absolute path for a container is in this mount point. If the relative path starts with `../` then the resource is outside of this mount point, but we can't simply check for this prefix because it misses `..` which is also outside of the mount, so check both.
func (*MountPoint) Path ¶ added in v1.10.0
func (m *MountPoint) Path() string
Path returns the path of a volume in a mount point.
func (*MountPoint) Setup ¶ added in v1.10.0
func (m *MountPoint) Setup(mountLabel string) (string, error)
Setup sets up a mount point by either mounting the volume if it is configured, or creating the source directory if supplied.
func (*MountPoint) Type ¶ added in v1.12.0
func (m *MountPoint) Type() string
Type returns the type of mount point
type ScopedVolume ¶ added in v1.12.0
ScopedVolume wraps a volume with a cluster scope (e.g., `local` or `global`)
type Volume ¶
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(id string) (string, error) // Unmount unmounts the volume when it is no longer in use. Unmount(id string) error // Status returns low-level status information about a volume Status() map[string]interface{} }
Volume is a place to store data. It is backed by a specific driver, and can be mounted.