2018-02-05 21:05:59 +00:00
|
|
|
package mount // import "github.com/docker/docker/api/types/mount"
|
2016-09-06 18:18:12 +00:00
|
|
|
|
2016-09-22 20:14:15 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2016-09-06 18:18:12 +00:00
|
|
|
// Type represents the type of a mount.
|
|
|
|
type Type string
|
|
|
|
|
2016-09-22 20:14:15 +00:00
|
|
|
// Type constants
|
2016-09-06 18:18:12 +00:00
|
|
|
const (
|
2016-09-22 20:14:15 +00:00
|
|
|
// TypeBind is the type for mounting host dir
|
2016-09-06 18:18:12 +00:00
|
|
|
TypeBind Type = "bind"
|
2016-09-22 20:14:15 +00:00
|
|
|
// TypeVolume is the type for remote storage volumes
|
2016-09-06 18:18:12 +00:00
|
|
|
TypeVolume Type = "volume"
|
2016-09-22 20:14:15 +00:00
|
|
|
// TypeTmpfs is the type for mounting tmpfs
|
|
|
|
TypeTmpfs Type = "tmpfs"
|
2017-07-31 21:23:52 +00:00
|
|
|
// TypeNamedPipe is the type for mounting Windows named pipes
|
|
|
|
TypeNamedPipe Type = "npipe"
|
2016-09-06 18:18:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Mount represents a mount (volume).
|
|
|
|
type Mount struct {
|
2016-09-22 20:14:15 +00:00
|
|
|
Type Type `json:",omitempty"`
|
|
|
|
// Source specifies the name of the mount. Depending on mount type, this
|
|
|
|
// may be a volume name or a host path, or even ignored.
|
|
|
|
// Source is not supported for tmpfs (must be an empty value)
|
2017-02-07 12:17:21 +00:00
|
|
|
Source string `json:",omitempty"`
|
|
|
|
Target string `json:",omitempty"`
|
|
|
|
ReadOnly bool `json:",omitempty"`
|
|
|
|
Consistency Consistency `json:",omitempty"`
|
2016-09-06 18:18:12 +00:00
|
|
|
|
|
|
|
BindOptions *BindOptions `json:",omitempty"`
|
|
|
|
VolumeOptions *VolumeOptions `json:",omitempty"`
|
2016-09-22 20:14:15 +00:00
|
|
|
TmpfsOptions *TmpfsOptions `json:",omitempty"`
|
2016-09-06 18:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Propagation represents the propagation of a mount.
|
|
|
|
type Propagation string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// PropagationRPrivate RPRIVATE
|
|
|
|
PropagationRPrivate Propagation = "rprivate"
|
|
|
|
// PropagationPrivate PRIVATE
|
|
|
|
PropagationPrivate Propagation = "private"
|
|
|
|
// PropagationRShared RSHARED
|
|
|
|
PropagationRShared Propagation = "rshared"
|
|
|
|
// PropagationShared SHARED
|
|
|
|
PropagationShared Propagation = "shared"
|
|
|
|
// PropagationRSlave RSLAVE
|
|
|
|
PropagationRSlave Propagation = "rslave"
|
|
|
|
// PropagationSlave SLAVE
|
|
|
|
PropagationSlave Propagation = "slave"
|
|
|
|
)
|
|
|
|
|
2016-11-30 21:34:29 +00:00
|
|
|
// Propagations is the list of all valid mount propagations
|
|
|
|
var Propagations = []Propagation{
|
|
|
|
PropagationRPrivate,
|
|
|
|
PropagationPrivate,
|
|
|
|
PropagationRShared,
|
|
|
|
PropagationShared,
|
|
|
|
PropagationRSlave,
|
|
|
|
PropagationSlave,
|
|
|
|
}
|
|
|
|
|
2017-02-07 12:17:21 +00:00
|
|
|
// Consistency represents the consistency requirements of a mount.
|
|
|
|
type Consistency string
|
|
|
|
|
|
|
|
const (
|
2017-08-19 14:23:38 +00:00
|
|
|
// ConsistencyFull guarantees bind mount-like consistency
|
2017-02-07 12:17:21 +00:00
|
|
|
ConsistencyFull Consistency = "consistent"
|
|
|
|
// ConsistencyCached mounts can cache read data and FS structure
|
|
|
|
ConsistencyCached Consistency = "cached"
|
|
|
|
// ConsistencyDelegated mounts can cache read and written data and structure
|
|
|
|
ConsistencyDelegated Consistency = "delegated"
|
|
|
|
// ConsistencyDefault provides "consistent" behavior unless overridden
|
|
|
|
ConsistencyDefault Consistency = "default"
|
|
|
|
)
|
|
|
|
|
2016-09-06 18:18:12 +00:00
|
|
|
// BindOptions defines options specific to mounts of type "bind".
|
|
|
|
type BindOptions struct {
|
|
|
|
Propagation Propagation `json:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeOptions represents the options for a mount of type volume.
|
|
|
|
type VolumeOptions struct {
|
|
|
|
NoCopy bool `json:",omitempty"`
|
|
|
|
Labels map[string]string `json:",omitempty"`
|
|
|
|
DriverConfig *Driver `json:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Driver represents a volume driver.
|
|
|
|
type Driver struct {
|
|
|
|
Name string `json:",omitempty"`
|
|
|
|
Options map[string]string `json:",omitempty"`
|
|
|
|
}
|
2016-09-22 20:14:15 +00:00
|
|
|
|
|
|
|
// TmpfsOptions defines options specific to mounts of type "tmpfs".
|
|
|
|
type TmpfsOptions struct {
|
|
|
|
// Size sets the size of the tmpfs, in bytes.
|
|
|
|
//
|
|
|
|
// This will be converted to an operating system specific value
|
2017-01-13 14:36:27 +00:00
|
|
|
// depending on the host. For example, on linux, it will be converted to
|
2016-09-22 20:14:15 +00:00
|
|
|
// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
|
|
|
|
// docker, uses a straight byte value.
|
|
|
|
//
|
|
|
|
// Percentages are not supported.
|
|
|
|
SizeBytes int64 `json:",omitempty"`
|
|
|
|
// Mode of the tmpfs upon creation
|
|
|
|
Mode os.FileMode `json:",omitempty"`
|
|
|
|
|
|
|
|
// TODO(stevvooe): There are several more tmpfs flags, specified in the
|
|
|
|
// daemon, that are accepted. Only the most basic are added for now.
|
|
|
|
//
|
|
|
|
// From docker/docker/pkg/mount/flags.go:
|
|
|
|
//
|
|
|
|
// var validFlags = map[string]bool{
|
|
|
|
// "": true,
|
|
|
|
// "size": true, X
|
|
|
|
// "mode": true, X
|
|
|
|
// "uid": true,
|
|
|
|
// "gid": true,
|
|
|
|
// "nr_inodes": true,
|
|
|
|
// "nr_blocks": true,
|
|
|
|
// "mpol": true,
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// Some of these may be straightforward to add, but others, such as
|
|
|
|
// uid/gid have implications in a clustered system.
|
|
|
|
}
|