mirror of
https://github.com/containers/podman-compose.git
synced 2024-11-22 16:03:16 +01:00
Support podman's external rootfs management
Signed-off-by: GnSight <ftyg@live.com>
This commit is contained in:
parent
12d46ca836
commit
77f2e8e5b0
@ -1145,12 +1145,22 @@ async def container_to_args(compose, cnt, detached=True):
|
||||
|
||||
# handle podman extension
|
||||
x_podman = cnt.get("x-podman", None)
|
||||
rootfs_mode = False
|
||||
if x_podman is not None:
|
||||
for uidmap in x_podman.get("uidmaps", []):
|
||||
podman_args.extend(["--uidmap", uidmap])
|
||||
for gidmap in x_podman.get("gidmaps", []):
|
||||
podman_args.extend(["--gidmap", gidmap])
|
||||
rootfs = x_podman.get("rootfs", None)
|
||||
if rootfs is not None:
|
||||
rootfs_mode = True
|
||||
podman_args.extend(["--rootfs", rootfs])
|
||||
log.warning(
|
||||
"WARNING: x-podman.rootfs and image both specified, \
|
||||
image field ignored"
|
||||
)
|
||||
|
||||
if not rootfs_mode:
|
||||
podman_args.append(cnt["image"]) # command, ..etc.
|
||||
command = cnt.get("command", None)
|
||||
if command is not None:
|
||||
@ -1831,7 +1841,9 @@ class PodmanCompose:
|
||||
"service_name": service_name,
|
||||
**service_desc,
|
||||
}
|
||||
if "image" not in cnt:
|
||||
x_podman = service_desc.get("x-podman", None)
|
||||
rootfs_mode = x_podman is not None and x_podman.get("rootfs", None) is not None
|
||||
if "image" not in cnt and not rootfs_mode:
|
||||
cnt["image"] = f"{project_name}_{service_name}"
|
||||
labels = norm_as_list(cnt.get("labels", None))
|
||||
cnt["ports"] = norm_ports(cnt.get("ports", None))
|
||||
|
@ -161,3 +161,25 @@ class TestContainerToArgs(unittest.IsolatedAsyncioTestCase):
|
||||
"busybox",
|
||||
],
|
||||
)
|
||||
|
||||
async def test_rootfs_extension(self):
|
||||
c = create_compose_mock()
|
||||
|
||||
cnt = get_minimal_container()
|
||||
del cnt["image"]
|
||||
cnt["x-podman"] = {
|
||||
"rootfs": "/path/to/rootfs",
|
||||
}
|
||||
|
||||
args = await container_to_args(c, cnt)
|
||||
self.assertEqual(
|
||||
args,
|
||||
[
|
||||
"--name=project_name_service_name1",
|
||||
"-d",
|
||||
"--network=bridge",
|
||||
"--network-alias=service_name",
|
||||
"--rootfs",
|
||||
"/path/to/rootfs",
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user