| ... | ... | @@ -284,6 +284,9 @@ def render(data, definitions): |
| 284 | 284 | host_network = any(task["hostNetwork"] for task in data["containers"].values()) |
| 285 | 285 | if host_network and not all(task["hostNetwork"] for task in data["containers"].values()): |
| 286 | 286 | raise ValueError("mixed host and bridge networking in one group") |
| 287 | restricted = any(task["restrictedEgress"] for task in data["containers"].values()) |
| 288 | if restricted and (host_network or not all(task["restrictedEgress"] for task in data["containers"].values())): |
| 289 | raise ValueError("restricted egress must cover every container in a bridge group") |
| 287 | 290 | for task_name, task in data["containers"].items(): |
| 288 | 291 | for kind, endpoint in [("http", task.get("http")), *((port["name"], port) for port in task["tcp"])]: |
| 289 | 292 | if endpoint: |
| ... | ... | @@ -299,10 +302,12 @@ def render(data, definitions): |
| 299 | 302 | if endpoint.get("loopback") or (not task["hostNetwork"] and kind == "http" and endpoint.get("hostPort") is None): |
| 300 | 303 | network.append(' host_network = "loopback"') |
| 301 | 304 | network.append(" }") |
| 302 | | if network: |
| 305 | if network or restricted: |
| 303 | 306 | lines.append(" network {") |
| 304 | 307 | if host_network: |
| 305 | 308 | lines.append(' mode = "host"') |
| 309 | elif restricted: |
| 310 | lines.append(' mode = "cni/sandbox"') |
| 306 | 311 | lines += network + [" }"] |
| 307 | 312 | for provider_id in sorted(dependencies(data)): |
| 308 | 313 | provider = definitions[provider_id] |
| ... | ... | @@ -403,7 +408,7 @@ def render(data, definitions): |
| 403 | 408 | if task.get("readOnlyRoot"): |
| 404 | 409 | lines.append(' readonly_rootfs = true') |
| 405 | 410 | task_ports = [label for (owner, _), label in ports.items() if owner == task_name] |
| 406 | | if task_ports and not task["hostNetwork"]: |
| 411 | if task_ports and not task["hostNetwork"] and not restricted: |
| 407 | 412 | lines.append(f" ports = {q(task_ports)}") |
| 408 | 413 | for field, values in (("cap_add", task["capAdd"]), ("devices", task["devices"]), ("extra_hosts", task["extraHosts"])): |
| 409 | 414 | if values: |