mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-22 08:29:18 +02:00
Extract get_net_args_from_network_mode()
Modified-by: Povilas Kanapickas <povilas@radix.lt> Signed-off-by: Songmin Li <lisongmin@protonmail.com>
This commit is contained in:
parent
d803c4c3e8
commit
a023dc145b
@ -877,15 +877,12 @@ async def assert_cnt_nets(compose, cnt):
|
||||
await compose.podman.output([], "network", ["exists", net_name])
|
||||
|
||||
|
||||
def get_net_args(compose, cnt):
|
||||
service_name = cnt["service_name"]
|
||||
def get_net_args_from_network_mode(compose, cnt):
|
||||
net_args = []
|
||||
is_bridge = False
|
||||
mac_address = cnt.get("mac_address")
|
||||
net = cnt.get("network_mode")
|
||||
if net:
|
||||
if net == "none":
|
||||
|
||||
is_bridge = False
|
||||
if net == "none":
|
||||
net_args.append("--network=none")
|
||||
elif net == "host":
|
||||
net_args.append(f"--network={net}")
|
||||
@ -909,6 +906,17 @@ def get_net_args(compose, cnt):
|
||||
else:
|
||||
log.fatal("unknown network_mode [%s]", net)
|
||||
sys.exit(1)
|
||||
|
||||
return net_args, is_bridge
|
||||
|
||||
|
||||
def get_net_args(compose, cnt):
|
||||
service_name = cnt["service_name"]
|
||||
net_args = []
|
||||
mac_address = cnt.get("mac_address")
|
||||
net = cnt.get("network_mode")
|
||||
if net:
|
||||
net_args, is_bridge = get_net_args_from_network_mode(compose, cnt)
|
||||
else:
|
||||
is_bridge = True
|
||||
cnt_nets = cnt.get("networks")
|
||||
|
Loading…
Reference in New Issue
Block a user