diff --git a/src/main/python/ddadevops/application/image_build_service.py b/src/main/python/ddadevops/application/image_build_service.py index 9c43c31..33a3d2d 100644 --- a/src/main/python/ddadevops/application/image_build_service.py +++ b/src/main/python/ddadevops/application/image_build_service.py @@ -3,10 +3,18 @@ from src.main.python.ddadevops.infrastructure import FileApi, ResourceApi, Image class ImageBuildService: - def __init__(self): - self.file_api = FileApi() - self.resource_api = ResourceApi() - self.image_api = ImageApi() + def __init__(self, file_api: FileApi, resource_api: ResourceApi, image_api: ImageApi): + self.file_api = file_api + self.resource_api = resource_api + self.image_api = image_api + + @classmethod + def prod(cls): + return cls( + FileApi(), + ResourceApi(), + ImageApi(), + ) def __copy_build_resource_file_from_package__(self, resource_name, devops: Devops): data = self.resource_api.read_resource(f"src/main/resources/docker/{resource_name}") diff --git a/src/main/python/ddadevops/devops_image_build.py b/src/main/python/ddadevops/devops_image_build.py index db55b7e..c5684bb 100644 --- a/src/main/python/ddadevops/devops_image_build.py +++ b/src/main/python/ddadevops/devops_image_build.py @@ -35,32 +35,32 @@ def create_devops_docker_build_config( class DevopsImageBuild(DevopsBuild): def __init__(self, project, input: dict): super().__init__(project, input) - self.image_build_service = ImageBuildService() - devops = self.repo.get_devops(self.project) + self.image_build_service = ImageBuildService.prod() + devops = self.devops_repo.get_devops(self.project) if BuildType.IMAGE not in devops.specialized_builds: raise ValueError(f"ImageBuild requires BuildType.IMAGE") def initialize_build_dir(self): super().initialize_build_dir() - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.initialize_build_dir(devops) def image(self): - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.image(devops) def drun(self): - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.drun(devops) def dockerhub_login(self): - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.dockerhub_login(devops) def dockerhub_publish(self): - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.dockerhub_publish(devops) def test(self): - devops = self.repo.get_devops(self.project) + devops = self.devops_repo.get_devops(self.project) self.image_build_service.test(devops) diff --git a/src/main/python/ddadevops/domain/init_service.py b/src/main/python/ddadevops/domain/init_service.py index 2f54d5a..e6d690e 100644 --- a/src/main/python/ddadevops/domain/init_service.py +++ b/src/main/python/ddadevops/domain/init_service.py @@ -20,6 +20,7 @@ class InitService: def initialize(self, input: dict) -> Devops: mixin_types = self.devops_factory.__parse_mixin_types__(input["mixin_types"]) + version = None if MixinType.RELEASE in mixin_types: primary_build_file_id = input.get("release_primary_build_file", "./project.clj") diff --git a/src/test/python/test_devops_build.py b/src/test/python/test_devops_build.py index c4c35b5..f31f738 100644 --- a/src/test/python/test_devops_build.py +++ b/src/test/python/test_devops_build.py @@ -6,14 +6,15 @@ from .domain.helper import devops_config from .resource_helper import copy_resource def test_devops_build(tmp_path): + str_tmp_path = str(tmp_path) copy_resource(Path('package.json'), tmp_path) - project = Project(str(tmp_path), name="name") + project = Project(str_tmp_path, name="name") devops_build = DevopsBuild( project, devops_config( { - "project_root_path": str(tmp_path), + "project_root_path": str_tmp_path, } ), ) diff --git a/src/test/python/test_image_build.py b/src/test/python/test_image_build.py index acb2f3b..71e99ec 100644 --- a/src/test/python/test_image_build.py +++ b/src/test/python/test_image_build.py @@ -1,16 +1,20 @@ import os from pybuilder.core import Project -from src.main.python.ddadevops.domain import Image, Devops -from src.main.python.ddadevops.devops_image_build import DevopsImageBuild -from .domain.test_helper import devops_config +from src.main.python.ddadevops import DevopsImageBuild +from .domain.helper import devops_config def test_devops_docker_build(tmp_path): - build_dir = "build" - project_name = "testing-project" - module_name = "docker-test" - tmp_path_str = str(tmp_path) - - project = Project(tmp_path_str, name=project_name) - image_build = DevopsImageBuild(project, devops_config({})) + str_tmp_path = str(tmp_path) + project = Project(str_tmp_path, name="name") + image_build = DevopsImageBuild( + project, + devops_config( + { + "project_root_path": str_tmp_path, + "build_types": ["IMAGE"], + "mixin_types": [], + } + ), + ) assert image_build