fix(buildman, endpoint): added in fix upload gzip and dockerfile
This commit is contained in:
parent
64cd139552
commit
df5a6aabe2
4 changed files with 63 additions and 19 deletions
|
@ -125,11 +125,11 @@ class BuildComponent(BaseComponent):
|
|||
# password: The password for pulling the base image (if any).
|
||||
|
||||
# TODO: Charlie Tuesday, March 28, 2017 come back and clean up build_subdir.
|
||||
dockerfile_path = os.path.relpath(build_config.get('build_subdir'), build_config.get('context'))
|
||||
context, dockerfile_path = self.extract_dockerfile_args(build_config)
|
||||
|
||||
build_arguments = {
|
||||
'build_package': build_job.get_build_package_url(self.user_files),
|
||||
'context': build_config.get('context'),
|
||||
'context': context,
|
||||
'dockerfile_path': dockerfile_path,
|
||||
'repository': repository_name,
|
||||
'registry': self.registry_hostname,
|
||||
|
@ -174,6 +174,18 @@ class BuildComponent(BaseComponent):
|
|||
# by this point, so it makes sense to have a timeout.
|
||||
self._last_heartbeat = datetime.datetime.utcnow() + BUILD_HEARTBEAT_DELAY
|
||||
|
||||
@staticmethod
|
||||
def extract_dockerfile_args(build_config):
|
||||
dockerfile_path = build_config.get('build_subdir', '')
|
||||
context = build_config.get('context', '')
|
||||
if not (dockerfile_path == '' or context == ''):
|
||||
# This should not happen and can be removed when we centralize validating build_config
|
||||
if ".." in os.path.relpath(dockerfile_path, context):
|
||||
return os.path.split(dockerfile_path)
|
||||
dockerfile_path = os.path.relpath(dockerfile_path, context)
|
||||
|
||||
return context, dockerfile_path
|
||||
|
||||
@staticmethod
|
||||
def _commit_sha(build_config):
|
||||
""" Determines whether the metadata is using an old schema or not and returns the commit. """
|
||||
|
|
|
@ -21,3 +21,15 @@ def test_path_is_dockerfile(input, expected_path, expected_file):
|
|||
actual_path, actual_file = BuildComponent.name_and_path(input)
|
||||
assert actual_path == expected_path
|
||||
assert actual_file == expected_file
|
||||
|
||||
@pytest.mark.parametrize('build_config,context,dockerfile_path', [
|
||||
({}, "", ""),
|
||||
({'build_subdir': "/builddir/Dockerfile"}, "", "/builddir/Dockerfile"),
|
||||
({'context': "/builddir"}, "/builddir", ""),
|
||||
({'context': "/builddir", 'build_subdir': "/builddir/Dockerfile"}, "/builddir", "Dockerfile"),
|
||||
({'context': "/some_other_dir/Dockerfile", 'build_subdir': "/builddir/Dockerfile"}, "/builddir", "Dockerfile"),
|
||||
])
|
||||
def test_extract_dockerfile_args(build_config, context, dockerfile_path):
|
||||
actual_context, actual_dockerfile_path = BuildComponent.extract_dockerfile_args(build_config)
|
||||
assert context == actual_context
|
||||
assert dockerfile_path == actual_dockerfile_path
|
||||
|
|
Reference in a new issue