Skip to content

Commit

Permalink
Merge pull request #1085 from jeremyvisser/fix-device-cgroup-rules
Browse files Browse the repository at this point in the history
Add device_cgroup_rules support
  • Loading branch information
p12tic authored Dec 6, 2024
2 parents d9fc8e9 + 054c66b commit 376f081
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/device_cgroup_rules.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for the "device_cgroup_rules" property in services.
2 changes: 2 additions & 0 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,8 @@ async def container_to_args(compose, cnt, detached=True):
podman_args.extend(["--group-add", item])
for item in cnt.get("devices", []):
podman_args.extend(["--device", item])
for item in cnt.get("device_cgroup_rules", []):
podman_args.extend(["--device-cgroup-rule", item])
for item in norm_as_list(cnt.get("dns")):
podman_args.extend(["--dns", item])
for item in norm_as_list(cnt.get("dns_opt")):
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/test_container_to_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,26 @@ async def test_network_default_name(self, name, is_compat, project_name, expecte
"busybox",
],
)

async def test_device(self):
c = create_compose_mock()
cnt = get_minimal_container()

cnt['devices'] = ['/dev/ttyS0']
cnt['device_cgroup_rules'] = ['c 100:200 rwm']

args = await container_to_args(c, cnt)
self.assertEqual(
args,
[
"--name=project_name_service_name1",
"-d",
"--device",
"/dev/ttyS0",
"--device-cgroup-rule",
"c 100:200 rwm",
"--network=bridge",
"--network-alias=service_name",
"busybox",
],
)

0 comments on commit 376f081

Please sign in to comment.