Skip to content

Commit 00a5086

Browse files
committed
chore: add dot attribute access to ContainerInfo
Signed-off-by: Khushiyant <khushiyant2002@gmail.com>
1 parent fd21bef commit 00a5086

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docker/api/container.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def __getattr__(self, item):
2626
This allows direct access to all fields without manually defining them.
2727
"""
2828
try:
29-
return self._info[item]
29+
value = self._info[item]
30+
if isinstance(value, dict):
31+
return ContainerInfo(value)
32+
return value
3033
except KeyError as err:
3134
raise AttributeError(
3235
f"'ContainerInfo' object has no attribute '{item}'"

tests/integration/api_container_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1587,4 +1587,5 @@ def test_container_info_object(self):
15871587

15881588
# attribute style access
15891589
assert inspect_data.Id == container['Id']
1590-
assert inspect_data["Id"] == container["Id"]
1590+
assert inspect_data.Config.Image == TEST_IMG
1591+
assert inspect_data.HostConfig.NetworkMode == 'bridge'

0 commit comments

Comments
 (0)