github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/api/types/mount/mount.go (about) 1 package mount // import "github.com/demonoid81/moby/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 ) 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 NonRecursive bool `json:",omitempty"` 84 } 85 86 // VolumeOptions represents the options for a mount of type volume. 87 type VolumeOptions struct { 88 NoCopy bool `json:",omitempty"` 89 Labels map[string]string `json:",omitempty"` 90 DriverConfig *Driver `json:",omitempty"` 91 } 92 93 // Driver represents a volume driver. 94 type Driver struct { 95 Name string `json:",omitempty"` 96 Options map[string]string `json:",omitempty"` 97 } 98 99 // TmpfsOptions defines options specific to mounts of type "tmpfs". 100 type TmpfsOptions struct { 101 // Size sets the size of the tmpfs, in bytes. 102 // 103 // This will be converted to an operating system specific value 104 // depending on the host. For example, on linux, it will be converted to 105 // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with 106 // docker, uses a straight byte value. 107 // 108 // Percentages are not supported. 109 SizeBytes int64 `json:",omitempty"` 110 // Mode of the tmpfs upon creation 111 Mode os.FileMode `json:",omitempty"` 112 113 // TODO(stevvooe): There are several more tmpfs flags, specified in the 114 // daemon, that are accepted. Only the most basic are added for now. 115 // 116 // From docker/docker/pkg/mount/flags.go: 117 // 118 // var validFlags = map[string]bool{ 119 // "": true, 120 // "size": true, X 121 // "mode": true, X 122 // "uid": true, 123 // "gid": true, 124 // "nr_inodes": true, 125 // "nr_blocks": true, 126 // "mpol": true, 127 // } 128 // 129 // Some of these may be straightforward to add, but others, such as 130 // uid/gid have implications in a clustered system. 131 }