Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of 'podman pod create --share=...' #620

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python_on_whales/components/pod/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def create(
replace: bool = False,
restart: Optional[str] = None,
security_options: List[str] = [],
share: List[str] = [],
share: Optional[List[str]] = None,
shm_size: Optional[Union[int, str]] = None,
subgidname: Optional[str] = None,
subuidname: Optional[str] = None,
Expand Down Expand Up @@ -441,7 +441,8 @@ def create(
full_cmd.add_flag("--replace", replace)
full_cmd.add_simple_arg("--restart", restart)
full_cmd.add_args_iterable_or_single("--security-opt", security_options)
full_cmd.add_args_iterable_or_single("--share", share)
if share is not None:
full_cmd.add_simple_arg("--share", ",".join(share))
full_cmd.add_simple_arg("--shm-size", shm_size)
full_cmd.add_simple_arg("--subgidname", subgidname)
full_cmd.add_simple_arg("--subuidname", subuidname)
Expand Down
4 changes: 3 additions & 1 deletion tests/python_on_whales/components/test_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,16 @@ def test_create_replace_arg(podman_client: DockerClient):

def test_create_share_arg(podman_client: DockerClient):
pod_name = random_name()
with podman_client.pod.create(pod_name, share=[]) as pod:
with podman_client.pod.create(pod_name, share=[], infra=True) as pod:
pod.start() # start the infra container
assert not pod.shared_namespaces
output = podman_client.container.run(
"ubuntu", ["readlink", "/proc/self"], pod=pod
)
assert output == "1"
with podman_client.pod.create(pod_name, share=["pid"]) as pod:
pod.start() # start the infra container (PID 1)
assert pod.shared_namespaces == ["pid"]
output = podman_client.container.run(
"ubuntu", ["readlink", "/proc/self"], pod=pod
)
Expand Down
Loading