Skip to content

Support uppercase mount attributes #487

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

Merged
merged 1 commit into from
Jan 7, 2025
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
8 changes: 5 additions & 3 deletions podman/domain/containers_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,12 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
args.pop("log_config")

for item in args.pop("mounts", []):
normalized_item = {key.lower(): value for key, value in item.items()}
mount_point = {
"destination": item.get("target"),
"destination": normalized_item.get("target"),
"options": [],
"source": item.get("source"),
"type": item.get("type"),
"source": normalized_item.get("source"),
"type": normalized_item.get("type"),
}

# some names are different for podman-py vs REST API due to compatibility with docker
Expand All @@ -570,6 +571,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
regular_options = ["consistency", "mode", "size"]

for k, v in item.items():
k = k.lower()
option_name = names_dict.get(k, k)
if k in bool_options and v is True:
options.append(option_name)
Expand Down
23 changes: 23 additions & 0 deletions podman/tests/integration/test_container_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,29 @@ def test_container_mounts(self):
)
)

with self.subTest("Check uppercase mount option attributes"):
mount = {
"TypE": "bind",
"SouRce": "/etc/hosts",
"TarGet": "/test",
"Read_Only": True,
"ReLabel": "Z",
}
container = self.client.containers.create(
self.alpine_image, command=["cat", "/test"], mounts=[mount]
)
self.containers.append(container)
self.assertIn(
f"{mount['SouRce']}:{mount['TarGet']}:ro,Z,rprivate,rbind",
container.attrs.get('HostConfig', {}).get('Binds', list()),
)

# check if container can be started and exits with EC == 0
container.start()
container.wait()

self.assertEqual(container.attrs.get('State', dict()).get('ExitCode', 256), 0)

def test_container_devices(self):
devices = ["/dev/null:/dev/foo", "/dev/zero:/dev/bar"]
container = self.client.containers.create(
Expand Down
Loading