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

rename working_dir to workdir for consistency #332

Closed
wants to merge 1 commit into from
Closed
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: 6 additions & 2 deletions podman/domain/containers_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
from contextlib import suppress
from typing import Any, Dict, List, MutableMapping, Union
import warnings

from podman import api
from podman.domain.containers import Container
Expand Down Expand Up @@ -287,7 +288,7 @@ def create(
}
volumes_from (List[str]): List of container names or IDs to get volumes from.
working_dir (str): Path to the working directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please retain this comment, see below.

workdir (str): Path to the working directory.
Returns:
A Container object.
Expand Down Expand Up @@ -403,6 +404,9 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
f"or int (found : {size_type})"
)

if "working_dir" in args:
warnings.warn("working_dir is deprecated, use workdir instead", PendingDeprecationWarning)

Comment on lines +407 to +409
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the warning. The library is intended to be a super set of the Docker SDK which uses working_dir as their parameter. I have no issue with workdir being added as an "alias".

# Transform keywords into parameters
params = {
"annotations": pop("annotations"), # TODO document, podman only
Expand Down Expand Up @@ -484,7 +488,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
"version": pop("version"),
"volumes": [],
"volumes_from": pop("volumes_from"),
"work_dir": pop("working_dir"),
"work_dir": pop("workdir") or pop("working_dir"),
}

for device in args.pop("devices", []):
Expand Down
6 changes: 6 additions & 0 deletions podman/tests/integration/test_container_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ def test_read_write_tmpfs(self):
print(inspect)
self.assertIn(expected_output, logs)

def test_container_working_dir_deprecation(self):
with self.assertWarns(PendingDeprecationWarning):
self.client.containers.create(
self.alpine_image, working_dir="/tmp", command=["/bin/ls", "-l", "/"]
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for including a test, but it will need to be adjusted to verify workdir works as expected.


if __name__ == '__main__':
unittest.main()
Loading