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:
commit
696ef7a19e
5 changed files with 17 additions and 13 deletions
|
@ -1444,13 +1444,13 @@ definitions:
|
||||||
Linux:
|
Linux:
|
||||||
type: "object"
|
type: "object"
|
||||||
x-nullable: false
|
x-nullable: false
|
||||||
required: [Capabilities, DeviceCreation, Devices]
|
required: [Capabilities, AllowAllDevices, Devices]
|
||||||
properties:
|
properties:
|
||||||
Capabilities:
|
Capabilities:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
type: "string"
|
type: "string"
|
||||||
DeviceCreation:
|
AllowAllDevices:
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
x-nullable: false
|
x-nullable: false
|
||||||
Devices:
|
Devices:
|
||||||
|
@ -1522,7 +1522,7 @@ definitions:
|
||||||
Type: ""
|
Type: ""
|
||||||
Linux:
|
Linux:
|
||||||
Capabilities: null
|
Capabilities: null
|
||||||
DeviceCreation: false
|
AllowAllDevices: false
|
||||||
Devices: null
|
Devices: null
|
||||||
Mounts: null
|
Mounts: null
|
||||||
PropagatedMount: "/data"
|
PropagatedMount: "/data"
|
||||||
|
@ -6364,7 +6364,7 @@ paths:
|
||||||
Type: ""
|
Type: ""
|
||||||
Linux:
|
Linux:
|
||||||
Capabilities: null
|
Capabilities: null
|
||||||
DeviceCreation: false
|
AllowAllDevices: false
|
||||||
Devices: null
|
Devices: null
|
||||||
Mounts: null
|
Mounts: null
|
||||||
PropagatedMount: "/data"
|
PropagatedMount: "/data"
|
||||||
|
|
|
@ -120,14 +120,14 @@ type PluginConfigInterface struct {
|
||||||
// swagger:model PluginConfigLinux
|
// swagger:model PluginConfigLinux
|
||||||
type PluginConfigLinux struct {
|
type PluginConfigLinux struct {
|
||||||
|
|
||||||
|
// allow all devices
|
||||||
|
// Required: true
|
||||||
|
AllowAllDevices bool `json:"AllowAllDevices"`
|
||||||
|
|
||||||
// capabilities
|
// capabilities
|
||||||
// Required: true
|
// Required: true
|
||||||
Capabilities []string `json:"Capabilities"`
|
Capabilities []string `json:"Capabilities"`
|
||||||
|
|
||||||
// device creation
|
|
||||||
// Required: true
|
|
||||||
DeviceCreation bool `json:"DeviceCreation"`
|
|
||||||
|
|
||||||
// devices
|
// devices
|
||||||
// Required: true
|
// Required: true
|
||||||
Devices []PluginDevice `json:"Devices"`
|
Devices []PluginDevice `json:"Devices"`
|
||||||
|
|
|
@ -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)
|
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*
|
- **`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)
|
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": {
|
"Linux": {
|
||||||
"Capabilities": null,
|
"Capabilities": null,
|
||||||
"DeviceCreation": false,
|
"AllowAllDevices": false,
|
||||||
"Devices": null
|
"Devices": null
|
||||||
},
|
},
|
||||||
"Mounts": null,
|
"Mounts": null,
|
||||||
|
|
|
@ -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{
|
privileges = append(privileges, types.PluginPrivilege{
|
||||||
Name: "device-creation",
|
Name: "allow-all-devices",
|
||||||
Description: "allow creating devices inside plugin",
|
Description: "allow 'rwm' access to all devices",
|
||||||
Value: []string{"true"},
|
Value: []string{"true"},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
|
||||||
s.Linux.RootfsPropagation = "rshared"
|
s.Linux.RootfsPropagation = "rshared"
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.PluginObj.Config.Linux.DeviceCreation {
|
if p.PluginObj.Config.Linux.AllowAllDevices {
|
||||||
rwm := "rwm"
|
rwm := "rwm"
|
||||||
s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
|
s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue