44from apluslms_yamlidator .utils .decorator import cached_property
55from apluslms_yamlidator .utils .collections import OrderedDict
66
7+ from apluslms_roman .utils .path_mapping import get_host_path
78from .backends import BACKENDS , BuildTask , BuildStep , Environment
89from .observer import StreamObserver
910from .utils .importing import import_string
@@ -36,7 +37,27 @@ def build(self, step_refs: list = None, host_path=None):
3637 backend = self ._engine .backend
3738 observer = self ._observer
3839 steps = self .get_steps (step_refs )
39- task = BuildTask (self .path if host_path is None else host_path , steps )
40+ # Check if has global config set.
41+ # Using path in global config file
42+ print ("dir mapping set in config:" , self ._engine ._dir_mapping if hasattr (self ._engine , '_dir_mapping' ) else None )
43+ print ("env set:" , self ._engine ._environment .environ .get ('DOCKER_HOST_PATH' , None ))
44+ print ("-p paramater set:" , host_path )
45+ if hasattr (self ._engine , '_dir_mapping' ):
46+ print ("Using roman config" )
47+ path = get_host_path (self .path , self ._engine ._dir_mapping )
48+ elif self ._engine ._environment .environ .get ('DOCKER_HOST_PATH' , None ) is not None :
49+ print ("Using DOCKER_HOST_PATH" )
50+ path = self ._engine ._environment .environ .get ('DOCKER_HOST_PATH' , None )
51+ elif host_path is not None :
52+ print ("Using -p parameter" )
53+ path = host_path
54+ else :
55+ path = self .path
56+ print ("No config find" )
57+ task = BuildTask (path , steps )
58+ # Using config file
59+ # Using -p flag or global environment variable
60+ # task = BuildTask(self.path if host_path is None else host_path, steps)
4061 observer .enter_prepare ()
4162 backend .prepare (task , observer )
4263 observer .enter_build ()
@@ -50,6 +71,9 @@ def __init__(self, backend_class=None, settings=None):
5071 if backend_class is None :
5172 if settings and 'backend' in settings :
5273 backend_class = settings ['backend' ]
74+ mapping = settings ['docker' ]['directory_map' ]
75+ if mapping is not None :
76+ self ._dir_mapping = dict (mapping )
5377 else :
5478 from .backends .docker import DockerBackend as backend_class
5579 if isinstance (backend_class , str ):
0 commit comments