summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-23 11:16:13 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-23 11:16:13 +0200
commit27095042decb58fb53766c190bb60adcb69805ef (patch)
treed68929d719833278beb783ea237f29803091a2dd /src/conf_mode
parente99cdf40c72dec8b9019eca728aaad0f82c6030b (diff)
downloadvyos-1x-27095042decb58fb53766c190bb60adcb69805ef.tar.gz
vyos-1x-27095042decb58fb53766c190bb60adcb69805ef.zip
containers: T2216: add missing verify() step on environment variables
A environment variable MUST always have a value specified. Non existing values will cause the following error: Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/containers.py", line 269, in <module> apply(c) File "/usr/libexec/vyos/conf_mode/containers.py", line 224, in apply env_opt += " -e ".join(f"{k}={v['value']}" for k, v in container_config['environment'].items()) File "/usr/libexec/vyos/conf_mode/containers.py", line 224, in <genexpr> env_opt += " -e ".join(f"{k}={v['value']}" for k, v in container_config['environment'].items()) KeyError: 'value'
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/containers.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py
index 7544bd840..b573df889 100755
--- a/src/conf_mode/containers.py
+++ b/src/conf_mode/containers.py
@@ -102,7 +102,6 @@ def verify(container):
if len(container_config['network']) > 1:
raise ConfigError(f'Only one network can be specified for container "{name}"!')
-
# Check if the specified container network exists
network_name = list(container_config['network'])[0]
if network_name not in container['network']:
@@ -127,6 +126,10 @@ def verify(container):
if ip_address(address) == ip_network(network)[1]:
raise ConfigError(f'Address "{address}" reserved for the container engine!')
+ if 'environment' in container_config:
+ for var, cfg in container_config['environment'].items():
+ if 'value' not in cfg:
+ raise ConfigError(f'Environment variable {var} has no value assigned!')
# Container image is a mandatory option
if 'image' not in container_config: