mirror of https://github.com/docker/docker-py.git
chore: add dot attribute access to ContainerInfo
Signed-off-by: Khushiyant <khushiyant2002@gmail.com>
This commit is contained in:
parent
fd21bef9f7
commit
00a5086d23
|
|
@ -26,7 +26,10 @@ class ContainerInfo:
|
||||||
This allows direct access to all fields without manually defining them.
|
This allows direct access to all fields without manually defining them.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self._info[item]
|
value = self._info[item]
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return ContainerInfo(value)
|
||||||
|
return value
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
f"'ContainerInfo' object has no attribute '{item}'"
|
f"'ContainerInfo' object has no attribute '{item}'"
|
||||||
|
|
|
||||||
|
|
@ -1587,4 +1587,5 @@ class ContainerInfoObjectTest(BaseAPIIntegrationTest):
|
||||||
|
|
||||||
# attribute style access
|
# attribute style access
|
||||||
assert inspect_data.Id == container['Id']
|
assert inspect_data.Id == container['Id']
|
||||||
assert inspect_data["Id"] == container["Id"]
|
assert inspect_data.Config.Image == TEST_IMG
|
||||||
|
assert inspect_data.HostConfig.NetworkMode == 'bridge'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue