From 8774ef9377610559d15071acec5442180c660924 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 23 Aug 2021 15:59:00 +0200 Subject: 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. --- src/conf_mode/containers.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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!') -- cgit v1.2.3