Merge pull request #2410 from charltonaustin/fix_subdir_parsing
fix(buildcomponent): fix dockerfile cases
This commit is contained in:
commit
9ed022fd18
2 changed files with 32 additions and 9 deletions
|
@ -124,15 +124,7 @@ class BuildComponent(BaseComponent):
|
||||||
# username: The username for pulling the base image (if any).
|
# username: The username for pulling the base image (if any).
|
||||||
# password: The password for pulling the base image (if any).
|
# password: The password for pulling the base image (if any).
|
||||||
|
|
||||||
subdir, dockerfile_name = os.path.split(build_config.get('build_subdir', '/Dockerfile'))
|
subdir, dockerfile_name = self.name_and_path(build_config.get('build_subdir'))
|
||||||
|
|
||||||
# HACK HACK HACK HACK HACK HACK HACK
|
|
||||||
# TODO: FIX THIS in the database and then turn the split back on.
|
|
||||||
if dockerfile_name.find('Dockerfile') < 0:
|
|
||||||
# This is a *HACK* for the broken path handling. To be fixed ASAP.
|
|
||||||
subdir = build_config.get('build_subdir') or '/'
|
|
||||||
dockerfile_name = 'Dockerfile'
|
|
||||||
# /HACK HACK HACK HACK HACK HACK HACK
|
|
||||||
|
|
||||||
build_arguments = {
|
build_arguments = {
|
||||||
'build_package': build_job.get_build_package_url(self.user_files),
|
'build_package': build_job.get_build_package_url(self.user_files),
|
||||||
|
@ -188,6 +180,14 @@ class BuildComponent(BaseComponent):
|
||||||
old_commit_sha = build_config['trigger_metadata'].get('commit_sha', '')
|
old_commit_sha = build_config['trigger_metadata'].get('commit_sha', '')
|
||||||
return commit_sha or old_commit_sha
|
return commit_sha or old_commit_sha
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def name_and_path(subdir):
|
||||||
|
""" Returns the dockerfile path and name """
|
||||||
|
if subdir.endswith("/"):
|
||||||
|
subdir += "Dockerfile"
|
||||||
|
elif not subdir.endswith("Dockerfile"):
|
||||||
|
subdir += "/Dockerfile"
|
||||||
|
return os.path.split(subdir)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _total_completion(statuses, total_images):
|
def _total_completion(statuses, total_images):
|
||||||
|
|
23
buildman/component/test/test_buildcomponent.py
Normal file
23
buildman/component/test/test_buildcomponent.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from buildman.component.buildcomponent import BuildComponent
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('input,expected_path,expected_file', [
|
||||||
|
("", "/", "Dockerfile"),
|
||||||
|
("/", "/", "Dockerfile"),
|
||||||
|
("/Dockerfile", "/", "Dockerfile"),
|
||||||
|
("/server.Dockerfile", "/", "server.Dockerfile"),
|
||||||
|
("/somepath", "/somepath", "Dockerfile"),
|
||||||
|
("/somepath/", "/somepath", "Dockerfile"),
|
||||||
|
("/somepath/Dockerfile", "/somepath", "Dockerfile"),
|
||||||
|
("/somepath/server.Dockerfile", "/somepath", "server.Dockerfile"),
|
||||||
|
("/somepath/some_other_path", "/somepath/some_other_path", "Dockerfile"),
|
||||||
|
("/somepath/some_other_path/", "/somepath/some_other_path", "Dockerfile"),
|
||||||
|
("/somepath/some_other_path/Dockerfile", "/somepath/some_other_path", "Dockerfile"),
|
||||||
|
("/somepath/some_other_path/server.Dockerfile", "/somepath/some_other_path", "server.Dockerfile"),
|
||||||
|
])
|
||||||
|
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
|
Reference in a new issue