Interpret 'build:' as relative to the yml file

* This fix introduces one side-effect: the build parameter is now
validated early, when the service dicionary is first constructed.
That leads to less scary stack traces when the path is not valid.

* The tests for the changes introduced here alter the fixtures
of those (otherwise unrelated) tests that make use of the 'build:'
parameter)

Signed-off-by: Moysés Borges Furtado <moyses.furtado@wplex.com.br>
This commit is contained in:
Moysés Borges 2015-03-29 17:06:35 -03:00 committed by Moysés Borges Furtado
commit 8584525e8d
7 changed files with 56 additions and 4 deletions

View file

@ -171,6 +171,9 @@ def process_container_options(service_dict, working_dir=None):
if 'volumes' in service_dict:
service_dict['volumes'] = resolve_host_paths(service_dict['volumes'], working_dir=working_dir)
if 'build' in service_dict:
service_dict['build'] = resolve_build_path(service_dict['build'], working_dir=working_dir)
return service_dict
@ -330,6 +333,17 @@ def resolve_host_path(volume, working_dir):
return container_path
def resolve_build_path(build_path, working_dir=None):
if working_dir is None:
raise Exception("No working_dir passed to resolve_build_path")
_path = expand_path(working_dir, build_path)
if not os.path.exists(_path) or not os.access(_path, os.R_OK):
raise ConfigurationError("build path %s either does not exist or is not accessible." % _path)
else:
return _path
def merge_volumes(base, override):
d = dict_from_volumes(base)
d.update(dict_from_volumes(override))