mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 03:46:55 +00:00
docker_image(_pull), docker_container: fix compatibility with Docker 29.0.0 (#1192)
* Add debug flag to failing task.
* Add more debug output.
* Fix pull idempotency.
* Revert "Add more debug output."
This reverts commit 64020149bf.
* Fix casing.
* Remove unreliable test.
* Add 'debug: true' to all tasks.
* Reformat.
* Fix idempotency problem for IPv6 addresses.
* Fix expose ranges handling.
* Update changelog fragment to also mention other affected modules.
This commit is contained in:
@@ -1970,10 +1970,20 @@ def _get_values_ports(
|
||||
config = container["Config"]
|
||||
|
||||
# "ExposedPorts": null returns None type & causes AttributeError - PR #5517
|
||||
expected_exposed: list[str] = []
|
||||
if config.get("ExposedPorts") is not None:
|
||||
expected_exposed = [_normalize_port(p) for p in config.get("ExposedPorts", {})]
|
||||
else:
|
||||
expected_exposed = []
|
||||
for port_and_protocol in config.get("ExposedPorts", {}):
|
||||
port, protocol = _normalize_port(port_and_protocol).rsplit("/")
|
||||
try:
|
||||
start, end = port.split("-", 1)
|
||||
start_port = int(start)
|
||||
end_port = int(end)
|
||||
for port_no in range(start_port, end_port + 1):
|
||||
expected_exposed.append(f"{port_no}/{protocol}")
|
||||
continue
|
||||
except ValueError:
|
||||
# Either it is not a range, or a broken one - in both cases, simply add the original form
|
||||
expected_exposed.append(f"{port}/{protocol}")
|
||||
|
||||
return {
|
||||
"published_ports": host_config.get("PortBindings"),
|
||||
@@ -2027,17 +2037,14 @@ def _get_expected_values_ports(
|
||||
]
|
||||
expected_values["published_ports"] = expected_bound_ports
|
||||
|
||||
image_ports = []
|
||||
image_ports: set[str] = set()
|
||||
if image:
|
||||
image_exposed_ports = image["Config"].get("ExposedPorts") or {}
|
||||
image_ports = [_normalize_port(p) for p in image_exposed_ports]
|
||||
param_ports = []
|
||||
image_ports = {_normalize_port(p) for p in image_exposed_ports}
|
||||
param_ports: set[str] = set()
|
||||
if "ports" in values:
|
||||
param_ports = [
|
||||
to_text(p[0], errors="surrogate_or_strict") + "/" + p[1]
|
||||
for p in values["ports"]
|
||||
]
|
||||
result = list(set(image_ports + param_ports))
|
||||
param_ports = {f"{p[0]}/{p[1]}" for p in values["ports"]}
|
||||
result = sorted(image_ports | param_ports)
|
||||
expected_values["exposed_ports"] = result
|
||||
|
||||
if "publish_all_ports" in values:
|
||||
|
||||
Reference in New Issue
Block a user