volume

package
v999.0.0-...-3a7701e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
const (
	// DefaultCopyMode is the copy mode used by default for normal/named volumes
	DefaultCopyMode = true
)
View Source
const DefaultDriverName = "local"

DefaultDriverName is the driver name used for the driver implemented in the local package.

View Source
const DefaultPropagationMode = mounttypes.PropagationRPrivate

DefaultPropagationMode defines what propagation mode should be used by default if user has not specified one explicitly. propagation modes

Variables

This section is empty.

Functions

func ConvertTmpfsOptions

func ConvertTmpfsOptions(opt *mounttypes.TmpfsOptions, readOnly bool) (string, error)

ConvertTmpfsOptions converts *mounttypes.TmpfsOptions to the raw option string for mount(2).

func GetPropagation

func GetPropagation(mode string) mounttypes.Propagation

GetPropagation extracts and returns the mount propagation mode. If there are no specifications, then by default it is "private".

func HasPropagation

func HasPropagation(mode string) bool

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

func IsVolumeNameValid(name string) (bool, error)

IsVolumeNameValid checks a volume name in a platform specific manner.

func MountPointAppliedMiddlewareOfAppliedMountPointMiddleware

func MountPointAppliedMiddlewareOfAppliedMountPointMiddleware(middleware []AppliedMountPointMiddleware) []types.MountPointAppliedMiddleware

func ParseVolumesFrom

func ParseVolumesFrom(spec string) (string, string, error)

ParseVolumesFrom ensures that the supplied volumes-from is valid.

func ReadWrite

func ReadWrite(mode string) bool

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

func ValidMountMode(mode string) bool

ValidMountMode will make sure the mount mode is valid. returns if it's a valid mount mode or not.

func ValidateTmpfsMountDestination

func ValidateTmpfsMountDestination(dest string) error

ValidateTmpfsMountDestination validates the destination of tmpfs mount. Currently, we have only two obvious rule for validation:

  • path must not be "/"
  • path must be absolute

We should add more rules carefully (#30166)

Types

type AppliedMountPointMiddleware

type AppliedMountPointMiddleware struct {
	Name string // Name is the name of the middleware (for later lookup)

	Changes   types.MountPointChanges            // Changes contains whatever changes the middleware has made to the mount
	Emergency []mountpoint.EmergencyDetachAction // Emergency contains a sequence of actions to perform at detach time in the event that the plugin cannot be reached
	Clock     int                                // Clock is a positive integer used to ensure mount detachments occur in the correct order
	// contains filtered or unexported fields
}

AppliedMountPointMiddleware represents a mount point middleware's application to a specific mount point. It tracks which middleware was applied (both referentially and directly -- necessary for serialization/deserialization), how the middleware changed the mount point if any, and the order of mount point application.

func (AppliedMountPointMiddleware) Middleware

Middleware will retrieve the Middleware object or create a new one if none is available

type Capability

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 DetailedVolume

type DetailedVolume interface {
	Labels() map[string]string
	Options() map[string]string
	Scope() string
	Volume
}

DetailedVolume wraps a Volume with user-defined labels, options, and cluster scope (e.g., `local` or `global`)

type Driver

type Driver interface {
	// Name returns the name of the volume driver.
	Name() string
	// Create makes a new volume with the given name.
	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. `global` or `local`).
	// Scope determines how the driver is handled at a cluster level
	Scope() string
}

Driver is for creating and removing volumes.

type MountPoint

type MountPoint struct {
	// Source is the source path of the mount.
	// E.g. `mount --bind /foo /bar`, `/foo` is the `Source`.
	Source string
	// Destination is the path relative to the container root (`/`) to the mount point
	// It is where the `Source` is mounted to
	Destination string
	// RW is set to true when the mountpoint should be mounted as read-write
	RW bool
	// Name is the name reference to the underlying data defined by `Source`
	// e.g., the volume name
	Name string
	// Driver is the volume driver used to create the volume (if it is a volume)
	Driver string
	// Type of mount to use, see `Type<foo>` definitions in github.com/docker/docker/api/types/mount
	Type mounttypes.Type `json:",omitempty"`
	// Volume is the volume providing data to this mountpoint.
	// This is nil unless `Type` is set to `TypeVolume`
	Volume Volume `json:"-"`

	// Mode is the comma separated list of options supplied by the user when creating
	// the bind/volume mount.
	// Note Mode is not used on Windows
	Mode string `json:"Relabel,omitempty"` // Originally field was `Relabel`"

	// Propagation describes how the mounts are propagated from the host into the
	// mount point, and vice-versa.
	// See https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
	// Note Propagation is not used on Windows
	Propagation mounttypes.Propagation `json:",omitempty"` // Mount propagation string

	// 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 `json:",omitempty"`

	// Spec is a copy of the API request that created this mount.
	Spec mounttypes.Mount

	// CreateSourceIfMissing indicates whether the source should be created
	// if it does not already exist (e.g. true for -v /missing:/mnt
	// and false for --mount)
	CreateSourceIfMissing bool

	// Consistency is the user-requested minimum consistency required
	// for file system data on the mount point
	Consistency mounttypes.Consistency

	// AppliedMiddleware is the stack of mount point middleware that has been applied to this mount
	AppliedMiddleware []AppliedMountPointMiddleware
	// contains filtered or unexported fields
}

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 ParseMountRaw

func ParseMountRaw(raw, volumeDriver string) (*MountPoint, error)

ParseMountRaw parses a raw volume spec (e.g. `-v /foo:/bar:shared`) into a structured spec. Once the raw spec is parsed it relies on `ParseMountSpec` to validate the spec and create a MountPoint

func ParseMountSpec

func ParseMountSpec(cfg mounttypes.Mount) (*MountPoint, error)

ParseMountSpec reads a mount config, validates it, and configures a mountpoint from it.

func (*MountPoint) BackwardsCompatible

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) Cleanup

func (m *MountPoint) Cleanup() error

Cleanup frees resources used by the mountpoint

func (*MountPoint) EffectiveConsistency

func (m *MountPoint) EffectiveConsistency() mount.Consistency

EffectiveConsistency is the consistency actually applied (rather than simply requested) to a mount point as middleware may have changed the consistency due to user annotation.

func (*MountPoint) EffectiveSource

func (m *MountPoint) EffectiveSource() string

EffectiveSource is the directory to use for a mount even after middleware may have changed the original source directory

func (*MountPoint) HasResource

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

func (m *MountPoint) Path() string

Path returns the path of a volume in a mount point.

func (*MountPoint) PopMiddleware

func (m *MountPoint) PopMiddleware() *AppliedMountPointMiddleware

PopMiddleware removes and returns a middleware from the mount point's middleware stack

func (*MountPoint) PushMiddleware

func (m *MountPoint) PushMiddleware(middleware mountpoint.Middleware, emergency []mountpoint.EmergencyDetachAction, changes types.MountPointChanges, clock int)

PushMiddleware pushes a new applied middleware onto the mount point's middleware stack

func (*MountPoint) Realize

func (m *MountPoint) Realize() error

Realize instantiates a mount point in preparation for mount point middleware application. In practice, this means that volumes are mounted and other mount types are unaffected. Postcondition: after a successful call, m.Source will contain the path of the mount point

func (*MountPoint) Setup

func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair) error

Setup prepares a mount point for immediate use by a container by creating the effective source directory for bind mounts and performing SELinux relabeling if necessary. The optional checkFun parameter allows additional checking before creating the source directory on the host.

func (*MountPoint) TopClock

func (m *MountPoint) TopClock() int

TopClock returns the Clock value from the middleware on the top of the mount point's middleware stack or 0 if the stack is empty

type MountPointChain

type MountPointChain struct {
	// contains filtered or unexported fields
}

MountPointChain uses a list of mount point middleware to interpose on mount point attachment and detachment

func NewMountPointChain

func NewMountPointChain(names []string, pg plugingetter.PluginGetter) (*MountPointChain, error)

NewMountPointChain creates a new Chain with a slice of plugin names.

func (*MountPointChain) AppendPluginIfMissing

func (c *MountPointChain) AppendPluginIfMissing(name string) error

AppendPluginIfMissing appends the mount point plugin named to the end of the chain if it isn't already in the chain

func (*MountPointChain) AttachMounts

func (c *MountPointChain) AttachMounts(image *container.Config, container *container.Config, id string, mounts []*MountPoint) error

AttachMounts runs a list of mount attachments through a mount point middleware chain

func (*MountPointChain) DetachMounts

func (c *MountPointChain) DetachMounts(container string, mounts map[string]*MountPoint) error

DetachMounts detaches mounts from a mount point middlware chain

func (*MountPointChain) DisableMountPointMiddleware

func (c *MountPointChain) DisableMountPointMiddleware(name string)

DisableMountPointMiddleware removes the mount point middleware from the chain

func (*MountPointChain) DisableMountPointPlugin

func (c *MountPointChain) DisableMountPointPlugin(name string)

DisableMountPointPlugin removes the mount point plugin from the chain

func (*MountPointChain) SetPlugins

func (c *MountPointChain) SetPlugins(names []string) (err error)

SetPlugins sets the mount point plugins in the chain

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
	// CreatedAt returns Volume Creation time
	CreatedAt() (time.Time, 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.

Directories

Path Synopsis
Package local provides the default implementation for volumes.
Package local provides the default implementation for volumes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL