mount.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package 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. )
  16. // Mount represents a mount (volume).
  17. type Mount struct {
  18. Type Type `json:",omitempty"`
  19. // Source specifies the name of the mount. Depending on mount type, this
  20. // may be a volume name or a host path, or even ignored.
  21. // Source is not supported for tmpfs (must be an empty value)
  22. Source string `json:",omitempty"`
  23. Target string `json:",omitempty"`
  24. ReadOnly bool `json:",omitempty"`
  25. BindOptions *BindOptions `json:",omitempty"`
  26. VolumeOptions *VolumeOptions `json:",omitempty"`
  27. TmpfsOptions *TmpfsOptions `json:",omitempty"`
  28. }
  29. // Propagation represents the propagation of a mount.
  30. type Propagation string
  31. const (
  32. // PropagationRPrivate RPRIVATE
  33. PropagationRPrivate Propagation = "rprivate"
  34. // PropagationPrivate PRIVATE
  35. PropagationPrivate Propagation = "private"
  36. // PropagationRShared RSHARED
  37. PropagationRShared Propagation = "rshared"
  38. // PropagationShared SHARED
  39. PropagationShared Propagation = "shared"
  40. // PropagationRSlave RSLAVE
  41. PropagationRSlave Propagation = "rslave"
  42. // PropagationSlave SLAVE
  43. PropagationSlave Propagation = "slave"
  44. )
  45. // Propagations is the list of all valid mount propagations
  46. var Propagations = []Propagation{
  47. PropagationRPrivate,
  48. PropagationPrivate,
  49. PropagationRShared,
  50. PropagationShared,
  51. PropagationRSlave,
  52. PropagationSlave,
  53. }
  54. // BindOptions defines options specific to mounts of type "bind".
  55. type BindOptions struct {
  56. Propagation Propagation `json:",omitempty"`
  57. }
  58. // VolumeOptions represents the options for a mount of type volume.
  59. type VolumeOptions struct {
  60. NoCopy bool `json:",omitempty"`
  61. Labels map[string]string `json:",omitempty"`
  62. DriverConfig *Driver `json:",omitempty"`
  63. }
  64. // Driver represents a volume driver.
  65. type Driver struct {
  66. Name string `json:",omitempty"`
  67. Options map[string]string `json:",omitempty"`
  68. }
  69. // TmpfsOptions defines options specific to mounts of type "tmpfs".
  70. type TmpfsOptions struct {
  71. // Size sets the size of the tmpfs, in bytes.
  72. //
  73. // This will be converted to an operating system specific value
  74. // depending on the host. For example, on linux, it will be converted to
  75. // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
  76. // docker, uses a straight byte value.
  77. //
  78. // Percentages are not supported.
  79. SizeBytes int64 `json:",omitempty"`
  80. // Mode of the tmpfs upon creation
  81. Mode os.FileMode `json:",omitempty"`
  82. // TODO(stevvooe): There are several more tmpfs flags, specified in the
  83. // daemon, that are accepted. Only the most basic are added for now.
  84. //
  85. // From docker/docker/pkg/mount/flags.go:
  86. //
  87. // var validFlags = map[string]bool{
  88. // "": true,
  89. // "size": true, X
  90. // "mode": true, X
  91. // "uid": true,
  92. // "gid": true,
  93. // "nr_inodes": true,
  94. // "nr_blocks": true,
  95. // "mpol": true,
  96. // }
  97. //
  98. // Some of these may be straightforward to add, but others, such as
  99. // uid/gid have implications in a clustered system.
  100. }