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:
|
class ImageBuildService:
|
||||||
def __init__(self):
|
def __init__(self, file_api: FileApi, resource_api: ResourceApi, image_api: ImageApi):
|
||||||
self.file_api = FileApi()
|
self.file_api = file_api
|
||||||
self.resource_api = ResourceApi()
|
self.resource_api = resource_api
|
||||||
self.image_api = ImageApi()
|
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):
|
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}")
|
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):
|
class DevopsImageBuild(DevopsBuild):
|
||||||
def __init__(self, project, input: dict):
|
def __init__(self, project, input: dict):
|
||||||
super().__init__(project, input)
|
super().__init__(project, input)
|
||||||
self.image_build_service = ImageBuildService()
|
self.image_build_service = ImageBuildService.prod()
|
||||||
devops = self.repo.get_devops(self.project)
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
if BuildType.IMAGE not in devops.specialized_builds:
|
if BuildType.IMAGE not in devops.specialized_builds:
|
||||||
raise ValueError(f"ImageBuild requires BuildType.IMAGE")
|
raise ValueError(f"ImageBuild requires BuildType.IMAGE")
|
||||||
|
|
||||||
def initialize_build_dir(self):
|
def initialize_build_dir(self):
|
||||||
super().initialize_build_dir()
|
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)
|
self.image_build_service.initialize_build_dir(devops)
|
||||||
|
|
||||||
def image(self):
|
def image(self):
|
||||||
devops = self.repo.get_devops(self.project)
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
self.image_build_service.image(devops)
|
self.image_build_service.image(devops)
|
||||||
|
|
||||||
def drun(self):
|
def drun(self):
|
||||||
devops = self.repo.get_devops(self.project)
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
self.image_build_service.drun(devops)
|
self.image_build_service.drun(devops)
|
||||||
|
|
||||||
def dockerhub_login(self):
|
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)
|
self.image_build_service.dockerhub_login(devops)
|
||||||
|
|
||||||
def dockerhub_publish(self):
|
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)
|
self.image_build_service.dockerhub_publish(devops)
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
devops = self.repo.get_devops(self.project)
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
self.image_build_service.test(devops)
|
self.image_build_service.test(devops)
|
||||||
|
|
|
@ -20,6 +20,7 @@ class InitService:
|
||||||
|
|
||||||
def initialize(self, input: dict) -> Devops:
|
def initialize(self, input: dict) -> Devops:
|
||||||
mixin_types = self.devops_factory.__parse_mixin_types__(input["mixin_types"])
|
mixin_types = self.devops_factory.__parse_mixin_types__(input["mixin_types"])
|
||||||
|
version = None
|
||||||
|
|
||||||
if MixinType.RELEASE in mixin_types:
|
if MixinType.RELEASE in mixin_types:
|
||||||
primary_build_file_id = input.get("release_primary_build_file", "./project.clj")
|
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
|
from .resource_helper import copy_resource
|
||||||
|
|
||||||
def test_devops_build(tmp_path):
|
def test_devops_build(tmp_path):
|
||||||
|
str_tmp_path = str(tmp_path)
|
||||||
copy_resource(Path('package.json'), 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(
|
devops_build = DevopsBuild(
|
||||||
project,
|
project,
|
||||||
devops_config(
|
devops_config(
|
||||||
{
|
{
|
||||||
"project_root_path": str(tmp_path),
|
"project_root_path": str_tmp_path,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
import os
|
import os
|
||||||
from pybuilder.core import Project
|
from pybuilder.core import Project
|
||||||
from src.main.python.ddadevops.domain import Image, Devops
|
from src.main.python.ddadevops import DevopsImageBuild
|
||||||
from src.main.python.ddadevops.devops_image_build import DevopsImageBuild
|
from .domain.helper import devops_config
|
||||||
from .domain.test_helper import devops_config
|
|
||||||
|
|
||||||
|
|
||||||
def test_devops_docker_build(tmp_path):
|
def test_devops_docker_build(tmp_path):
|
||||||
build_dir = "build"
|
str_tmp_path = str(tmp_path)
|
||||||
project_name = "testing-project"
|
project = Project(str_tmp_path, name="name")
|
||||||
module_name = "docker-test"
|
image_build = DevopsImageBuild(
|
||||||
tmp_path_str = str(tmp_path)
|
project,
|
||||||
|
devops_config(
|
||||||
project = Project(tmp_path_str, name=project_name)
|
{
|
||||||
image_build = DevopsImageBuild(project, devops_config({}))
|
"project_root_path": str_tmp_path,
|
||||||
|
"build_types": ["IMAGE"],
|
||||||
|
"mixin_types": [],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
assert image_build
|
assert image_build
|
||||||
|
|
Loading…
Reference in a new issue