docker_container: add driver_opts and gw_priority (#1143)

closes #1142
This commit is contained in:
salty
2025-10-07 18:26:25 +02:00
committed by GitHub
parent d0f4ef57a4
commit ebb8569b5f
4 changed files with 49 additions and 0 deletions
@@ -255,11 +255,25 @@ class DockerAPIEngineDriver(EngineDriver):
"links": "Links",
"aliases": "Aliases",
"mac_address": "MacAddress",
"driver_opts": "DriverOpts",
}.items():
value = parameters.pop(para, None)
if value:
if para == "links":
value = normalize_links(value)
elif para == "driver_opts":
# Ensure driver_opts values are strings
for key, val in value.items():
if not isinstance(val, str):
raise Exception(
f"driver_opts values must be strings, got {type(val).__name__} for key '{key}'"
)
params[dest_para] = value
for para, dest_para in {
"gw_priority": "GwPriority",
}.items():
value = parameters.pop(para, None)
if value is not None:
params[dest_para] = value
if parameters:
ups = ", ".join([f'"{p}"' for p in sorted(parameters)])
@@ -1785,6 +1799,20 @@ OPTION_NETWORK.add_engine(
for net_info in (c.module.params["networks"] or [])
),
},
"networks.driver_opts": {
"docker_api_version": "1.32",
"detect_usage": lambda c: any(
net_info.get("driver_opts") is not None
for net_info in (c.module.params["networks"] or [])
),
},
"networks.gw_priority": {
"docker_api_version": "1.48",
"detect_usage": lambda c: any(
net_info.get("gw_priority") is not None
for net_info in (c.module.params["networks"] or [])
),
},
},
),
)