|
1 | 1 | package mount |
2 | 2 |
|
| 3 | +import ( |
| 4 | + "os" |
| 5 | +) |
| 6 | + |
3 | 7 | // Type represents the type of a mount. |
4 | 8 | type Type string |
5 | 9 |
|
| 10 | +// Type constants |
6 | 11 | const ( |
7 | | - // TypeBind BIND |
| 12 | + // TypeBind is the type for mounting host dir |
8 | 13 | TypeBind Type = "bind" |
9 | | - // TypeVolume VOLUME |
| 14 | + // TypeVolume is the type for remote storage volumes |
10 | 15 | TypeVolume Type = "volume" |
| 16 | + // TypeTmpfs is the type for mounting tmpfs |
| 17 | + TypeTmpfs Type = "tmpfs" |
11 | 18 | ) |
12 | 19 |
|
13 | 20 | // Mount represents a mount (volume). |
14 | 21 | type Mount struct { |
15 | | - Type Type `json:",omitempty"` |
| 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) |
16 | 26 | Source string `json:",omitempty"` |
17 | 27 | Target string `json:",omitempty"` |
18 | 28 | ReadOnly bool `json:",omitempty"` |
19 | 29 |
|
20 | 30 | BindOptions *BindOptions `json:",omitempty"` |
21 | 31 | VolumeOptions *VolumeOptions `json:",omitempty"` |
| 32 | + TmpfsOptions *TmpfsOptions `json:",omitempty"` |
22 | 33 | } |
23 | 34 |
|
24 | 35 | // Propagation represents the propagation of a mount. |
@@ -56,3 +67,37 @@ type Driver struct { |
56 | 67 | Name string `json:",omitempty"` |
57 | 68 | Options map[string]string `json:",omitempty"` |
58 | 69 | } |
| 70 | + |
| 71 | +// TmpfsOptions defines options specific to mounts of type "tmpfs". |
| 72 | +type TmpfsOptions struct { |
| 73 | + // Size sets the size of the tmpfs, in bytes. |
| 74 | + // |
| 75 | + // This will be converted to an operating system specific value |
| 76 | + // depending on the host. For example, on linux, it will be convered to |
| 77 | + // use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with |
| 78 | + // docker, uses a straight byte value. |
| 79 | + // |
| 80 | + // Percentages are not supported. |
| 81 | + SizeBytes int64 `json:",omitempty"` |
| 82 | + // Mode of the tmpfs upon creation |
| 83 | + Mode os.FileMode `json:",omitempty"` |
| 84 | + |
| 85 | + // TODO(stevvooe): There are several more tmpfs flags, specified in the |
| 86 | + // daemon, that are accepted. Only the most basic are added for now. |
| 87 | + // |
| 88 | + // From docker/docker/pkg/mount/flags.go: |
| 89 | + // |
| 90 | + // var validFlags = map[string]bool{ |
| 91 | + // "": true, |
| 92 | + // "size": true, X |
| 93 | + // "mode": true, X |
| 94 | + // "uid": true, |
| 95 | + // "gid": true, |
| 96 | + // "nr_inodes": true, |
| 97 | + // "nr_blocks": true, |
| 98 | + // "mpol": true, |
| 99 | + // } |
| 100 | + // |
| 101 | + // Some of these may be straightforward to add, but others, such as |
| 102 | + // uid/gid have implications in a clustered system. |
| 103 | +} |
0 commit comments