feat(build runner): added in context, dockerfile_location
this is a new feature meant to allow people to use any file as a dockerfile and any folder as a context directory
This commit is contained in:
parent
90b130fe16
commit
e6d201e0b0
29 changed files with 531 additions and 111 deletions
|
@ -1,44 +1,9 @@
|
|||
import os
|
||||
|
||||
|
||||
def _get_config_expand(config):
|
||||
""" Get config with both context and dockerfile_path written to it """
|
||||
if config and "subdir" in config and "context" not in config:
|
||||
config_expand = dict(config)
|
||||
config_expand["context"] = _create_context(config["subdir"])
|
||||
config_expand["dockerfile_path"] = _create_dockerfile_path(config["subdir"])
|
||||
return config_expand
|
||||
return config or {}
|
||||
if not config:
|
||||
return {}
|
||||
if 'context' in config:
|
||||
config['subdir'] = config['context']
|
||||
|
||||
|
||||
def _create_context(current_subdir):
|
||||
""" Create context from current subdir """
|
||||
if current_subdir.endswith("Dockerfile"):
|
||||
context, _ = os.path.split(current_subdir)
|
||||
if context == "":
|
||||
return os.path.sep
|
||||
|
||||
return context
|
||||
|
||||
if current_subdir == "":
|
||||
current_subdir = os.path.sep + current_subdir
|
||||
|
||||
if current_subdir[len(current_subdir) - 1] != os.path.sep:
|
||||
current_subdir += os.path.sep
|
||||
|
||||
context, _ = os.path.split(current_subdir)
|
||||
return context
|
||||
|
||||
|
||||
def _create_dockerfile_path(current_subdir):
|
||||
""" Create dockefile path from current subdir """
|
||||
if current_subdir.endswith("Dockerfile"):
|
||||
return current_subdir
|
||||
|
||||
if current_subdir == "":
|
||||
current_subdir = os.path.sep + current_subdir
|
||||
|
||||
if current_subdir[len(current_subdir) - 1] != os.path.sep:
|
||||
current_subdir += os.path.sep
|
||||
|
||||
return current_subdir + "Dockerfile"
|
||||
return config
|
||||
|
|
Reference in a new issue