Add network "disable-dns" support

Podman allows to create a network disabling the DNS plugin with
'--disable-dns', but this option is not available in the compose spec.

This patch add 'x-podman.disable-dns' to the podman-compose options,
allowing the creation of a network with the DNS plugin disabled.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
This commit is contained in:
Rafael Guterres Jeffman 2025-01-17 12:14:15 -03:00
parent 84f1fbd622
commit 6e642dca1f
4 changed files with 35 additions and 0 deletions

View File

@ -27,6 +27,14 @@ services:
For explanations of these extensions, please refer to the [Podman Documentation](https://docs.podman.io/).
## Network management
The following extension keys are available under network configuration:
* `x-podman.disable-dns` - Disable the DNS plugin for the network when set to 'true'.
For explanations of these extensions, please refer to the
[Podman network create command Documentation](https://docs.podman.io/en/latest/markdown/podman-network-create.1.html).
## Per-network MAC-addresses

View File

@ -0,0 +1 @@
- Add support for 'x-podman.disable-dns' to allow disabling DNS plugin on defined networks.

View File

@ -833,6 +833,8 @@ def get_network_create_args(net_desc, proj_name, net_name):
ipam_config_ls = ipam.get("config", [])
if net_desc.get("enable_ipv6"):
args.append("--ipv6")
if net_desc.get("x-podman.disable_dns"):
args.append("--disable-dns")
if isinstance(ipam_config_ls, dict):
ipam_config_ls = [ipam_config_ls]

View File

@ -201,3 +201,27 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
]
args = get_network_create_args(net_desc, proj_name, net_name)
self.assertEqual(args, expected_args)
def test_disable_dns(self):
net_desc = {
"labels": [],
"internal": False,
"driver": None,
"driver_opts": {},
"ipam": {"config": []},
"enable_ipv6": False,
"x-podman.disable_dns": True,
}
proj_name = "test_project"
net_name = "test_network"
expected_args = [
"create",
"--label",
f"io.podman.compose.project={proj_name}",
"--label",
f"com.docker.compose.project={proj_name}",
"--disable-dns",
net_name,
]
args = get_network_create_args(net_desc, proj_name, net_name)
self.assertEqual(args, expected_args)