Skip to content

Commit 2623ffe

Browse files
authored
Merge pull request #65 from elezar/add-type-field-for-mounts
[spec] Add type field for mounts
2 parents 59be731 + 2de8d7e commit 2623ffe

File tree

8 files changed

+40
-11
lines changed

8 files changed

+40
-11
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Additionally runtimes don't uniformly expose a plugin system (or even expose a p
2525
$ mkdir /etc/cdi
2626
$ cat > /etc/cdi/vendor.json <<EOF
2727
{
28-
"cdiVersion": "0.3.0",
28+
"cdiVersion": "0.4.0",
2929
"kind": "vendor.com/device",
3030
"devices": [
3131
{
@@ -48,7 +48,8 @@ $ cat > /etc/cdi/vendor.json <<EOF
4848
],
4949
"mounts": [
5050
{"hostPath": "/bin/vendorBin", "containerPath": "/bin/vendorBin"},
51-
{"hostPath": "/usr/lib/libVendor.so.0", "containerPath": "/usr/lib/libVendor.so.0"}
51+
{"hostPath": "/usr/lib/libVendor.so.0", "containerPath": "/usr/lib/libVendor.so.0"},
52+
{"hostPath": "tmpfs", "containerPath": "/tmp/data", "type": "tmpfs", "options": ["nosuid","strictatime","mode=755","size=65536k"]}
5253
],
5354
"hooks": [
5455
{"createContainer": {"path": "/bin/vendor-hook"} },

SPEC.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Version
1010

11-
This is CDI **spec** version **0.3.0**.
11+
This is CDI **spec** version **0.4.0**.
1212

1313
### Update policy
1414

@@ -24,6 +24,7 @@ Released versions of the spec are available as Git tags.
2424
| Tag | Spec Permalink | Change |
2525
| -----| -----------------| -------|
2626
| v0.3.0 | | Initial tagged release of Spec |
27+
| v0.4.0 | | Added `type` field to Mount specification |
2728

2829
*Note*: The initial release of a **spec** with version `v0.x.0` will be tagged as
2930
`v0.x.0` with subsequent changes to the API applicable to this version tagged as `v0.x.y`.
@@ -120,7 +121,8 @@ The key words "must", "must not", "required", "shall", "shall not", "should", "s
120121
{
121122
"hostPath": "<source>",
122123
"containerPath": "<destination>",
123-
"options": "<OCI Mount Options>", (optional)
124+
"type": "<OCI Mount Type>", (optional)
125+
"options": "<OCI Mount Options>" (optional)
124126
}
125127
],
126128
"hooks": [ (optional)
@@ -192,11 +194,8 @@ The `containerEdits` field has the following definition:
192194
* `mounts` (array of objects, OPTIONAL) describes the mounts that should be mounted:
193195
* `hostPath` (string, REQUIRED) path of the device on the host.
194196
* `containerPath` (string, REQUIRED) path of the device within the container.
195-
* `readonly` (boolean, OPTIONAL) If set, the mount is read-only.
196-
* `propagation` (string, OPTIONAL) Requested propagation mode, candidates are one of:
197-
* private - No mount propagation ("private" in Linux terminology).
198-
* hostToContainer - Mounts get propagated from the host to the container ("rslave" in Linux terminology).
199-
* bidirectional - Mounts get propagated from the host to the container and from the container to the host ("rshared" in Linux terminology).
197+
* `type` (string, OPTIONAL) the type of the filesystem to be mounted. For bind mounts (when options include either bind or rbind), the type is a dummy, often "none" (not listed in /proc/filesystems).
198+
* `options` (array of strings, OPTIONAL) Mount options of the filesystem to be used.
200199
* `hooks` (array of objects, OPTIONAL) describes the hooks that should be ran:
201200
* `hookName` is the name of the hook to invoke, if the runtime is OCI compliant it should be one of {createRuntime, createContainer, startContainer, poststart, poststop}.
202201
Runtimes are free to allow custom hooks but it is advised for vendors to create a specific JSON file targeting that runtime

pkg/cdi/spec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
"0.1.0": {},
3535
"0.2.0": {},
3636
"0.3.0": {},
37+
"0.4.0": {},
3738
}
3839

3940
// Externally set CDI Spec validation function.

pkg/cdi/spec_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,29 @@ devices:
293293
containerEdits:
294294
env:
295295
- "FOO=BAR"
296+
`,
297+
vendor: "vendor.com",
298+
class: "device",
299+
},
300+
{
301+
name: "valid",
302+
priority: 1,
303+
data: `
304+
cdiVersion: "0.4.0"
305+
kind: vendor.com/device
306+
devices:
307+
- name: "dev1"
308+
containerEdits:
309+
mounts:
310+
- hostPath: "tmpfs"
311+
containerPath: "/usr/local/container"
312+
type: "tmpfs"
313+
options:
314+
- "ro"
315+
- "mode=755"
316+
- "size=65536k"
317+
env:
318+
- "FOO=BAR"
296319
`,
297320
vendor: "vendor.com",
298321
class: "device",

schema/defs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
},
6464
"options": {
6565
"$ref": "#/definitions/ArrayOfStrings"
66+
},
67+
"type": {
68+
"type": "string"
6669
}
6770
},
6871
"required": [

schema/testdata/good/spec-example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cdiVersion": "0.3.0",
2+
"cdiVersion": "0.4.0",
33
"kind": "vendor.com/device",
44
"devices": [
55
{

specs-go/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package specs
33
import "os"
44

55
// CurrentVersion is the current version of the Spec.
6-
const CurrentVersion = "0.3.0"
6+
const CurrentVersion = "0.4.0"
77

88
// Spec is the base configuration for CDI
99
type Spec struct {
@@ -45,6 +45,7 @@ type Mount struct {
4545
HostPath string `json:"hostPath"`
4646
ContainerPath string `json:"containerPath"`
4747
Options []string `json:"options,omitempty"`
48+
Type string `json:"type,omitempty"`
4849
}
4950

5051
// Hook represents a hook that needs to be added to the OCI spec.

specs-go/oci.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (m *Mount) ToOCI() spec.Mount {
9595
Source: m.HostPath,
9696
Destination: m.ContainerPath,
9797
Options: m.Options,
98+
Type: m.Type,
9899
}
99100
}
100101

0 commit comments

Comments
 (0)