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