summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-23 15:59:00 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-23 15:59:02 +0200
commit8774ef9377610559d15071acec5442180c660924 (patch)
treec70bbd6a8f5cb9fe46adf563fb60f00efa706fa7 /src
parentc48566ead61cb7c7c0571167c75d78b7fb6aa759 (diff)
downloadvyos-1x-8774ef9377610559d15071acec5442180c660924.tar.gz
vyos-1x-8774ef9377610559d15071acec5442180c660924.zip
container: T2216: verify() volume paths
Volumes must have both a source and destination path specified. Also the source path must exist on the current system.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/containers.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py
index 2c4861449..97e84a5bb 100755
--- a/src/conf_mode/containers.py
+++ b/src/conf_mode/containers.py
@@ -122,6 +122,18 @@ def verify(container):
if 'value' not in cfg:
raise ConfigError(f'Environment variable {var} has no value assigned!')
+ if 'volume' in container_config:
+ for volume, volume_config in container_config['volume'].items():
+ if 'source' not in volume_config:
+ raise ConfigError(f'Volume "{volume}" has no source path configured!')
+
+ if 'destination' not in volume_config:
+ raise ConfigError(f'Volume "{volume}" has no destination path configured!')
+
+ source = volume_config['source']
+ if not os.path.exists(source):
+ raise ConfigError(f'Volume "{volume}" source path "{source}" does not exist!')
+
# Container image is a mandatory option
if 'image' not in container_config:
raise ConfigError(f'Container image for "{name}" is mandatory!')