mount.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // BindOptions defines options specific to mounts of type "bind".
  46. type BindOptions struct {
  47. Propagation Propagation `json:",omitempty"`
  48. }
  49. // VolumeOptions represents the options for a mount of type volume.
  50. type VolumeOptions struct {
  51. NoCopy bool `json:",omitempty"`
  52. Labels map[string]string `json:",omitempty"`
  53. DriverConfig *Driver `json:",omitempty"`
  54. }
  55. // Driver represents a volume driver.
  56. type Driver struct {
  57. Name string `json:",omitempty"`
  58. Options map[string]string `json:",omitempty"`
  59. }
  60. // TmpfsOptions defines options specific to mounts of type "tmpfs".
  61. type TmpfsOptions struct {
  62. // Size sets the size of the tmpfs, in bytes.
  63. //
  64. // This will be converted to an operating system specific value
  65. // depending on the host. For example, on linux, it will be convered to
  66. // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
  67. // docker, uses a straight byte value.
  68. //
  69. // Percentages are not supported.
  70. SizeBytes int64 `json:",omitempty"`
  71. // Mode of the tmpfs upon creation
  72. Mode os.FileMode `json:",omitempty"`
  73. // TODO(stevvooe): There are several more tmpfs flags, specified in the
  74. // daemon, that are accepted. Only the most basic are added for now.
  75. //
  76. // From docker/docker/pkg/mount/flags.go:
  77. //
  78. // var validFlags = map[string]bool{
  79. // "": true,
  80. // "size": true, X
  81. // "mode": true, X
  82. // "uid": true,
  83. // "gid": true,
  84. // "nr_inodes": true,
  85. // "nr_blocks": true,
  86. // "mpol": true,
  87. // }
  88. //
  89. // Some of these may be straightforward to add, but others, such as
  90. // uid/gid have implications in a clustered system.
  91. }