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