github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/api/types/mount/mount.go (about) 1 package mount 2 3 import ( 4 "os" 5 ) 6 7 // Type represents the type of a mount. 8 type Type string 9 10 // Type constants 11 const ( 12 // TypeBind is the type for mounting host dir 13 TypeBind Type = "bind" 14 // TypeVolume is the type for remote storage volumes 15 TypeVolume Type = "volume" 16 // TypeTmpfs is the type for mounting tmpfs 17 TypeTmpfs Type = "tmpfs" 18 ) 19 20 // Mount represents a mount (volume). 21 type Mount struct { 22 Type Type `json:",omitempty"` 23 // Source specifies the name of the mount. Depending on mount type, this 24 // may be a volume name or a host path, or even ignored. 25 // Source is not supported for tmpfs (must be an empty value) 26 Source string `json:",omitempty"` 27 Target string `json:",omitempty"` 28 ReadOnly bool `json:",omitempty"` 29 Consistency Consistency `json:",omitempty"` 30 31 BindOptions *BindOptions `json:",omitempty"` 32 VolumeOptions *VolumeOptions `json:",omitempty"` 33 TmpfsOptions *TmpfsOptions `json:",omitempty"` 34 } 35 36 // Propagation represents the propagation of a mount. 37 type Propagation string 38 39 const ( 40 // PropagationRPrivate RPRIVATE 41 PropagationRPrivate Propagation = "rprivate" 42 // PropagationPrivate PRIVATE 43 PropagationPrivate Propagation = "private" 44 // PropagationRShared RSHARED 45 PropagationRShared Propagation = "rshared" 46 // PropagationShared SHARED 47 PropagationShared Propagation = "shared" 48 // PropagationRSlave RSLAVE 49 PropagationRSlave Propagation = "rslave" 50 // PropagationSlave SLAVE 51 PropagationSlave Propagation = "slave" 52 ) 53 54 // Propagations is the list of all valid mount propagations 55 var Propagations = []Propagation{ 56 PropagationRPrivate, 57 PropagationPrivate, 58 PropagationRShared, 59 PropagationShared, 60 PropagationRSlave, 61 PropagationSlave, 62 } 63 64 // Consistency represents the consistency requirements of a mount. 65 type Consistency string 66 67 const ( 68 // ConsistencyFull guarantees bind-mount-like consistency 69 ConsistencyFull Consistency = "consistent" 70 // ConsistencyCached mounts can cache read data and FS structure 71 ConsistencyCached Consistency = "cached" 72 // ConsistencyDelegated mounts can cache read and written data and structure 73 ConsistencyDelegated Consistency = "delegated" 74 // ConsistencyDefault provides "consistent" behavior unless overridden 75 ConsistencyDefault Consistency = "default" 76 ) 77 78 // BindOptions defines options specific to mounts of type "bind". 79 type BindOptions struct { 80 Propagation Propagation `json:",omitempty"` 81 } 82 83 // VolumeOptions represents the options for a mount of type volume. 84 type VolumeOptions struct { 85 NoCopy bool `json:",omitempty"` 86 Labels map[string]string `json:",omitempty"` 87 DriverConfig *Driver `json:",omitempty"` 88 } 89 90 // Driver represents a volume driver. 91 type Driver struct { 92 Name string `json:",omitempty"` 93 Options map[string]string `json:",omitempty"` 94 } 95 96 // TmpfsOptions defines options specific to mounts of type "tmpfs". 97 type TmpfsOptions struct { 98 // Size sets the size of the tmpfs, in bytes. 99 // 100 // This will be converted to an operating system specific value 101 // depending on the host. For example, on linux, it will be converted to 102 // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with 103 // docker, uses a straight byte value. 104 // 105 // Percentages are not supported. 106 SizeBytes int64 `json:",omitempty"` 107 // Mode of the tmpfs upon creation 108 Mode os.FileMode `json:",omitempty"` 109 110 // TODO(stevvooe): There are several more tmpfs flags, specified in the 111 // daemon, that are accepted. Only the most basic are added for now. 112 // 113 // From docker/docker/pkg/mount/flags.go: 114 // 115 // var validFlags = map[string]bool{ 116 // "": true, 117 // "size": true, X 118 // "mode": true, X 119 // "uid": true, 120 // "gid": true, 121 // "nr_inodes": true, 122 // "nr_blocks": true, 123 // "mpol": true, 124 // } 125 // 126 // Some of these may be straightforward to add, but others, such as 127 // uid/gid have implications in a clustered system. 128 }