mv domain logic to domain
This commit is contained in:
parent
355c457d57
commit
771ffe5229
2 changed files with 15 additions and 16 deletions
|
@ -4,7 +4,9 @@ from ..infrastructure import FileApi, ResourceApi, ImageApi
|
||||||
|
|
||||||
|
|
||||||
class ImageBuildService:
|
class ImageBuildService:
|
||||||
def __init__(self, file_api: FileApi, resource_api: ResourceApi, image_api: ImageApi):
|
def __init__(
|
||||||
|
self, file_api: FileApi, resource_api: ResourceApi, image_api: ImageApi
|
||||||
|
):
|
||||||
self.file_api = file_api
|
self.file_api = file_api
|
||||||
self.resource_api = resource_api
|
self.resource_api = resource_api
|
||||||
self.image_api = image_api
|
self.image_api = image_api
|
||||||
|
@ -18,7 +20,9 @@ class ImageBuildService:
|
||||||
)
|
)
|
||||||
|
|
||||||
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}"
|
||||||
|
)
|
||||||
self.file_api.write_data_to_file(
|
self.file_api.write_data_to_file(
|
||||||
Path(f"{devops.build_path()}/{resource_name}"), data
|
Path(f"{devops.build_path()}/{resource_name}"), data
|
||||||
)
|
)
|
||||||
|
@ -30,9 +34,7 @@ class ImageBuildService:
|
||||||
|
|
||||||
def __copy_build_resources_from_dir__(self, devops: Devops):
|
def __copy_build_resources_from_dir__(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
self.file_api.cp_force(
|
self.file_api.cp_force(image.build_commons_path(), devops.build_path())
|
||||||
image.build_commons_path(), devops.build_path()
|
|
||||||
)
|
|
||||||
|
|
||||||
def initialize_build_dir(self, devops: Devops):
|
def initialize_build_dir(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
@ -61,9 +63,13 @@ class ImageBuildService:
|
||||||
|
|
||||||
def dockerhub_publish(self, devops: Devops):
|
def dockerhub_publish(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
if image.image_tag is not None:
|
||||||
self.image_api.dockerhub_publish(
|
self.image_api.dockerhub_publish(
|
||||||
image.image_name(), image.image_dockerhub_user, image.image_tag
|
image.image_name(), image.image_dockerhub_user, image.image_tag
|
||||||
)
|
)
|
||||||
|
self.image_api.dockerhub_publish(
|
||||||
|
image.image_name(), image.image_dockerhub_user, 'latest'
|
||||||
|
)
|
||||||
|
|
||||||
def test(self, devops: Devops):
|
def test(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
|
|
@ -67,20 +67,13 @@ class ImageApi:
|
||||||
f"docker login --username {username} --password {password}"
|
f"docker login --username {username} --password {password}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def dockerhub_publish(self, name: str, username: str, tag=None):
|
def dockerhub_publish(self, name: str, username: str, tag: str):
|
||||||
if tag is not None:
|
|
||||||
self.execution_api.execute_live(
|
self.execution_api.execute_live(
|
||||||
f"docker tag {name} {username}/{name}:{tag}"
|
f"docker tag {name} {username}/{name}:{tag}"
|
||||||
)
|
)
|
||||||
self.execution_api.execute_live(
|
self.execution_api.execute_live(
|
||||||
f"docker push {username}/{name}:{tag}"
|
f"docker push {username}/{name}:{tag}"
|
||||||
)
|
)
|
||||||
self.execution_api.execute_live(
|
|
||||||
f"docker tag {name} {username}/{name}:latest"
|
|
||||||
)
|
|
||||||
self.execution_api.execute_live(
|
|
||||||
f"docker push {username}/{name}:latest"
|
|
||||||
)
|
|
||||||
|
|
||||||
def test(self, name: str, path: Path):
|
def test(self, name: str, path: Path):
|
||||||
self.execution_api.execute_live(
|
self.execution_api.execute_live(
|
||||||
|
|
Loading…
Reference in a new issue