devops image build now may work
This commit is contained in:
parent
a13bda5a30
commit
73e73e8d3d
5 changed files with 38 additions and 24 deletions
|
@ -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}")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue