mirror of
https://github.com/containers/podman-compose.git
synced 2024-11-29 03:15:06 +01:00
Merge pull request #851 from fccagou/fix-ipam-driver-default
fix(ipam_driver): do not pass --ipam-driver option when value set to …
This commit is contained in:
commit
33d7d35a4d
@ -734,7 +734,7 @@ def get_network_create_args(net_desc, proj_name, net_name):
|
|||||||
args.extend(("--opt", f"{key}={value}"))
|
args.extend(("--opt", f"{key}={value}"))
|
||||||
ipam = net_desc.get("ipam", None) or {}
|
ipam = net_desc.get("ipam", None) or {}
|
||||||
ipam_driver = ipam.get("driver", None)
|
ipam_driver = ipam.get("driver", None)
|
||||||
if ipam_driver:
|
if ipam_driver and ipam_driver != "default":
|
||||||
args.extend(("--ipam-driver", ipam_driver))
|
args.extend(("--ipam-driver", ipam_driver))
|
||||||
ipam_config_ls = ipam.get("config", None) or []
|
ipam_config_ls = ipam.get("config", None) or []
|
||||||
if net_desc.get("enable_ipv6", None):
|
if net_desc.get("enable_ipv6", None):
|
||||||
|
@ -77,7 +77,7 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
|
|||||||
args = get_network_create_args(net_desc, proj_name, net_name)
|
args = get_network_create_args(net_desc, proj_name, net_name)
|
||||||
self.assertEqual(args, expected_args)
|
self.assertEqual(args, expected_args)
|
||||||
|
|
||||||
def test_ipam_driver(self):
|
def test_ipam_driver_default(self):
|
||||||
net_desc = {
|
net_desc = {
|
||||||
"labels": [],
|
"labels": [],
|
||||||
"internal": False,
|
"internal": False,
|
||||||
@ -96,6 +96,42 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
proj_name = "test_project"
|
proj_name = "test_project"
|
||||||
net_name = "test_network"
|
net_name = "test_network"
|
||||||
|
expected_args = [
|
||||||
|
"create",
|
||||||
|
"--label",
|
||||||
|
f"io.podman.compose.project={proj_name}",
|
||||||
|
"--label",
|
||||||
|
f"com.docker.compose.project={proj_name}",
|
||||||
|
"--subnet",
|
||||||
|
"192.168.0.0/24",
|
||||||
|
"--ip-range",
|
||||||
|
"192.168.0.2/24",
|
||||||
|
"--gateway",
|
||||||
|
"192.168.0.1",
|
||||||
|
net_name,
|
||||||
|
]
|
||||||
|
args = get_network_create_args(net_desc, proj_name, net_name)
|
||||||
|
self.assertEqual(args, expected_args)
|
||||||
|
|
||||||
|
def test_ipam_driver(self):
|
||||||
|
net_desc = {
|
||||||
|
"labels": [],
|
||||||
|
"internal": False,
|
||||||
|
"driver": None,
|
||||||
|
"driver_opts": {},
|
||||||
|
"ipam": {
|
||||||
|
"driver": "someipamdriver",
|
||||||
|
"config": [
|
||||||
|
{
|
||||||
|
"subnet": "192.168.0.0/24",
|
||||||
|
"ip_range": "192.168.0.2/24",
|
||||||
|
"gateway": "192.168.0.1",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
proj_name = "test_project"
|
||||||
|
net_name = "test_network"
|
||||||
expected_args = [
|
expected_args = [
|
||||||
"create",
|
"create",
|
||||||
"--label",
|
"--label",
|
||||||
@ -103,7 +139,7 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
|
|||||||
"--label",
|
"--label",
|
||||||
f"com.docker.compose.project={proj_name}",
|
f"com.docker.compose.project={proj_name}",
|
||||||
"--ipam-driver",
|
"--ipam-driver",
|
||||||
"default",
|
"someipamdriver",
|
||||||
"--subnet",
|
"--subnet",
|
||||||
"192.168.0.0/24",
|
"192.168.0.0/24",
|
||||||
"--ip-range",
|
"--ip-range",
|
||||||
@ -122,7 +158,7 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
|
|||||||
"driver": "bridge",
|
"driver": "bridge",
|
||||||
"driver_opts": {"opt1": "value1", "opt2": "value2"},
|
"driver_opts": {"opt1": "value1", "opt2": "value2"},
|
||||||
"ipam": {
|
"ipam": {
|
||||||
"driver": "default",
|
"driver": "someipamdriver",
|
||||||
"config": [
|
"config": [
|
||||||
{
|
{
|
||||||
"subnet": "192.168.0.0/24",
|
"subnet": "192.168.0.0/24",
|
||||||
@ -153,7 +189,7 @@ class TestGetNetworkCreateArgs(unittest.TestCase):
|
|||||||
"--opt",
|
"--opt",
|
||||||
"opt2=value2",
|
"opt2=value2",
|
||||||
"--ipam-driver",
|
"--ipam-driver",
|
||||||
"default",
|
"someipamdriver",
|
||||||
"--ipv6",
|
"--ipv6",
|
||||||
"--subnet",
|
"--subnet",
|
||||||
"192.168.0.0/24",
|
"192.168.0.0/24",
|
||||||
|
15
tests/ipam_default/docker-compose.yaml
Normal file
15
tests/ipam_default/docker-compose.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
# --ipam-driver must not be pass when driver is "default"
|
||||||
|
networks:
|
||||||
|
ipam_test_default:
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: 172.19.0.0/24
|
||||||
|
|
||||||
|
services:
|
||||||
|
testipam:
|
||||||
|
image: busybox
|
||||||
|
command: ["echo", "ipamtest"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user