Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Added fix for path-based validators
Browse files Browse the repository at this point in the history
We support using lxdock from subfolders but Voluptuous doesn't play well in this context, especially for configuration values corresponding
to paths relative to the directory containing the LXDock configuration file. For now we'll just chdir to the homedir (containing the LXDock
file) in order to perform schema validations.
  • Loading branch information
ellmetha committed Mar 30, 2017
1 parent 2eda9ea commit f57207e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lxdock/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ def from_base_dir(cls, base_dir='.'):
# Loads the YML.
config.load()

# Validates the content of the configuration.
# Validates the content of the configuration. We chdir into the home directory of the
# project in order to ensure that IsFile/IsDir validators keep working properly if the
# config is initialized from a subfolder of the project.
cwd = os.getcwd()
os.chdir(config.homedir)
try:
schema(config._dict)
except Invalid as e:
# Formats the voluptuous error
path = ' @ %s' % '.'.join(map(str, e.path)) if e.path else ''
msg = 'The LXDock file is invalid because: {0}'.format(e.msg + path)
raise ConfigFileValidationError(msg)
finally:
os.chdir(cwd)

# Loads the containers.
config.load_containers()
Expand Down

0 comments on commit f57207e

Please sign in to comment.