1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #30014 from tiborvass/plugin-devices-redone-master

Plugins: Rename DeviceCreation to AllowAllDevices
This commit is contained in:
Tibor Vass 2017-01-10 17:24:38 -08:00 committed by GitHub
commit 696ef7a19e
5 changed files with 17 additions and 13 deletions

View file

@ -1444,13 +1444,13 @@ definitions:
Linux:
type: "object"
x-nullable: false
required: [Capabilities, DeviceCreation, Devices]
required: [Capabilities, AllowAllDevices, Devices]
properties:
Capabilities:
type: "array"
items:
type: "string"
DeviceCreation:
AllowAllDevices:
type: "boolean"
x-nullable: false
Devices:
@ -1522,7 +1522,7 @@ definitions:
Type: ""
Linux:
Capabilities: null
DeviceCreation: false
AllowAllDevices: false
Devices: null
Mounts: null
PropagatedMount: "/data"
@ -6364,7 +6364,7 @@ paths:
Type: ""
Linux:
Capabilities: null
DeviceCreation: false
AllowAllDevices: false
Devices: null
Mounts: null
PropagatedMount: "/data"

View file

@ -120,14 +120,14 @@ type PluginConfigInterface struct {
// swagger:model PluginConfigLinux
type PluginConfigLinux struct {
// allow all devices
// Required: true
AllowAllDevices bool `json:"AllowAllDevices"`
// capabilities
// Required: true
Capabilities []string `json:"Capabilities"`
// device creation
// Required: true
DeviceCreation bool `json:"DeviceCreation"`
// devices
// Required: true
Devices []PluginDevice `json:"Devices"`

View file

@ -153,6 +153,10 @@ Config provides the base accessible fields for working with V0 plugin format
capabilities of the plugin (*Linux only*), see list [`here`](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md#security)
- **`allowAllDevices`** *boolean*
If `/dev` is bind mounted from the host, and allowAllDevices is set to true, the plugin will have `rwm` access to all devices on the host.
- **`devices`** *PluginDevice array*
device of the plugin, (*Linux only*), struct consisting of the following fields, see [`DEVICES`](https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#devices)
@ -205,7 +209,7 @@ Config provides the base accessible fields for working with V0 plugin format
},
"Linux": {
"Capabilities": null,
"DeviceCreation": false,
"AllowAllDevices": false,
"Devices": null
},
"Mounts": null,

View file

@ -159,10 +159,10 @@ func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) {
})
}
}
if c.Linux.DeviceCreation {
if c.Linux.AllowAllDevices {
privileges = append(privileges, types.PluginPrivilege{
Name: "device-creation",
Description: "allow creating devices inside plugin",
Name: "allow-all-devices",
Description: "allow 'rwm' access to all devices",
Value: []string{"true"},
})
}

View file

@ -87,7 +87,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
s.Linux.RootfsPropagation = "rshared"
}
if p.PluginObj.Config.Linux.DeviceCreation {
if p.PluginObj.Config.Linux.AllowAllDevices {
rwm := "rwm"
s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
}