Skip to content

Commit

Permalink
Handle empty devices in OCI spec
Browse files Browse the repository at this point in the history
Signed-off-by: Zvonko Kaiser <[email protected]>
  • Loading branch information
zvonkok committed Jun 12, 2024
1 parent 7d34603 commit a9c4a82
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/generate/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,25 @@ impl Generator {
self.init_config_linux_resources();
if let Some(linux) = self.config.as_mut().unwrap().linux_mut() {
if let Some(resource) = linux.resources_mut() {
if let Some(devices) = resource.devices_mut() {

let add_device = |allow, dev_type, major, minor, access| {
let mut device = LinuxDeviceCgroup::default();
device.set_allow(allow);
device.set_typ(Some(dev_type));
device.set_major(major);
device.set_minor(minor);
device.set_access(access);
device
};

let device = add_device(allow, dev_type, major, minor, access);

if let Some(devices) = resource.devices_mut() {
devices.push(device);
} else {
let mut devices = Vec::new();
devices.push(device);
resource.set_devices(Some(devices));
}
}
}
Expand Down

0 comments on commit a9c4a82

Please sign in to comment.