mount.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package mount // import "github.com/docker/docker/api/types/mount"
  2. import (
  3. "os"
  4. )
  5. // Type represents the type of a mount.
  6. type Type string
  7. // Type constants
  8. const (
  9. // TypeBind is the type for mounting host dir
  10. TypeBind Type = "bind"
  11. // TypeVolume is the type for remote storage volumes
  12. TypeVolume Type = "volume"
  13. // TypeTmpfs is the type for mounting tmpfs
  14. TypeTmpfs Type = "tmpfs"
  15. // TypeNamedPipe is the type for mounting Windows named pipes
  16. TypeNamedPipe Type = "npipe"
  17. // TypeCluster is the type for Swarm Cluster Volumes.
  18. TypeCluster Type = "cluster"
  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"` // attempts recursive read-only if possible
  29. Consistency Consistency `json:",omitempty"`
  30. BindOptions *BindOptions `json:",omitempty"`
  31. VolumeOptions *VolumeOptions `json:",omitempty"`
  32. TmpfsOptions *TmpfsOptions `json:",omitempty"`
  33. ClusterOptions *ClusterOptions `json:",omitempty"`
  34. }
  35. // Propagation represents the propagation of a mount.
  36. type Propagation string
  37. const (
  38. // PropagationRPrivate RPRIVATE
  39. PropagationRPrivate Propagation = "rprivate"
  40. // PropagationPrivate PRIVATE
  41. PropagationPrivate Propagation = "private"
  42. // PropagationRShared RSHARED
  43. PropagationRShared Propagation = "rshared"
  44. // PropagationShared SHARED
  45. PropagationShared Propagation = "shared"
  46. // PropagationRSlave RSLAVE
  47. PropagationRSlave Propagation = "rslave"
  48. // PropagationSlave SLAVE
  49. PropagationSlave Propagation = "slave"
  50. )
  51. // Propagations is the list of all valid mount propagations
  52. var Propagations = []Propagation{
  53. PropagationRPrivate,
  54. PropagationPrivate,
  55. PropagationRShared,
  56. PropagationShared,
  57. PropagationRSlave,
  58. PropagationSlave,
  59. }
  60. // Consistency represents the consistency requirements of a mount.
  61. type Consistency string
  62. const (
  63. // ConsistencyFull guarantees bind mount-like consistency
  64. ConsistencyFull Consistency = "consistent"
  65. // ConsistencyCached mounts can cache read data and FS structure
  66. ConsistencyCached Consistency = "cached"
  67. // ConsistencyDelegated mounts can cache read and written data and structure
  68. ConsistencyDelegated Consistency = "delegated"
  69. // ConsistencyDefault provides "consistent" behavior unless overridden
  70. ConsistencyDefault Consistency = "default"
  71. )
  72. // BindOptions defines options specific to mounts of type "bind".
  73. type BindOptions struct {
  74. Propagation Propagation `json:",omitempty"`
  75. NonRecursive bool `json:",omitempty"`
  76. CreateMountpoint bool `json:",omitempty"`
  77. // ReadOnlyNonRecursive makes the mount non-recursively read-only, but still leaves the mount recursive
  78. // (unless NonRecursive is set to true in conjunction).
  79. ReadOnlyNonRecursive bool `json:",omitempty"`
  80. // ReadOnlyForceRecursive raises an error if the mount cannot be made recursively read-only.
  81. ReadOnlyForceRecursive bool `json:",omitempty"`
  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. // Driver represents a volume driver.
  90. type Driver struct {
  91. Name string `json:",omitempty"`
  92. Options map[string]string `json:",omitempty"`
  93. }
  94. // TmpfsOptions defines options specific to mounts of type "tmpfs".
  95. type TmpfsOptions struct {
  96. // Size sets the size of the tmpfs, in bytes.
  97. //
  98. // This will be converted to an operating system specific value
  99. // depending on the host. For example, on linux, it will be converted to
  100. // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
  101. // docker, uses a straight byte value.
  102. //
  103. // Percentages are not supported.
  104. SizeBytes int64 `json:",omitempty"`
  105. // Mode of the tmpfs upon creation
  106. Mode os.FileMode `json:",omitempty"`
  107. // TODO(stevvooe): There are several more tmpfs flags, specified in the
  108. // daemon, that are accepted. Only the most basic are added for now.
  109. //
  110. // From https://github.com/moby/sys/blob/mount/v0.1.1/mount/flags.go#L47-L56
  111. //
  112. // var validFlags = map[string]bool{
  113. // "": true,
  114. // "size": true, X
  115. // "mode": true, X
  116. // "uid": true,
  117. // "gid": true,
  118. // "nr_inodes": true,
  119. // "nr_blocks": true,
  120. // "mpol": true,
  121. // }
  122. //
  123. // Some of these may be straightforward to add, but others, such as
  124. // uid/gid have implications in a clustered system.
  125. }
  126. // ClusterOptions specifies options for a Cluster volume.
  127. type ClusterOptions struct {
  128. // intentionally empty
  129. }