From 1ef7ba760bc7c21a754ef7cf3e5049ec88739b12 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 25 Dec 2022 11:00:04 +0100 Subject: container: T2216: add verify() for port definition If port is specified on the CLI so must be source and destination under the port node. --- src/conf_mode/container.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index 8efeaed54..48ba409a8 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -168,6 +168,11 @@ def verify(container): if not os.path.exists(source): raise ConfigError(f'Volume "{volume}" source path "{source}" does not exist!') + if 'port' in container_config: + for tmp in container_config['port']: + if not {'source', 'destination'} <= set(container_config['port'][tmp]): + raise ConfigError(f'Both "source" and "destination" must be specified for a port mapping!') + # If 'allow-host-networks' or 'network' not set. if 'allow_host_networks' not in container_config and 'network' not in container_config: raise ConfigError(f'Must either set "network" or "allow-host-networks" for container "{name}"!') -- cgit v1.2.3