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:
|
||||
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.resource_api = resource_api
|
||||
self.image_api = image_api
|
||||
|
@ -18,7 +20,9 @@ class ImageBuildService:
|
|||
)
|
||||
|
||||
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(
|
||||
Path(f"{devops.build_path()}/{resource_name}"), data
|
||||
)
|
||||
|
@ -30,9 +34,7 @@ class ImageBuildService:
|
|||
|
||||
def __copy_build_resources_from_dir__(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
self.file_api.cp_force(
|
||||
image.build_commons_path(), devops.build_path()
|
||||
)
|
||||
self.file_api.cp_force(image.build_commons_path(), devops.build_path())
|
||||
|
||||
def initialize_build_dir(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
|
@ -61,8 +63,12 @@ class ImageBuildService:
|
|||
|
||||
def dockerhub_publish(self, devops: Devops):
|
||||
image = devops.specialized_builds[BuildType.IMAGE]
|
||||
if image.image_tag is not None:
|
||||
self.image_api.dockerhub_publish(
|
||||
image.image_name(), image.image_dockerhub_user, image.image_tag
|
||||
)
|
||||
self.image_api.dockerhub_publish(
|
||||
image.image_name(), image.image_dockerhub_user, image.image_tag
|
||||
image.image_name(), image.image_dockerhub_user, 'latest'
|
||||
)
|
||||
|
||||
def test(self, devops: Devops):
|
||||
|
|
|
@ -67,19 +67,12 @@ class ImageApi:
|
|||
f"docker login --username {username} --password {password}"
|
||||
)
|
||||
|
||||
def dockerhub_publish(self, name: str, username: str, tag=None):
|
||||
if tag is not None:
|
||||
self.execution_api.execute_live(
|
||||
f"docker tag {name} {username}/{name}:{tag}"
|
||||
)
|
||||
self.execution_api.execute_live(
|
||||
f"docker push {username}/{name}:{tag}"
|
||||
)
|
||||
def dockerhub_publish(self, name: str, username: str, tag: str):
|
||||
self.execution_api.execute_live(
|
||||
f"docker tag {name} {username}/{name}:latest"
|
||||
f"docker tag {name} {username}/{name}:{tag}"
|
||||
)
|
||||
self.execution_api.execute_live(
|
||||
f"docker push {username}/{name}:latest"
|
||||
f"docker push {username}/{name}:{tag}"
|
||||
)
|
||||
|
||||
def test(self, name: str, path: Path):
|
||||
|
|
Loading…
Reference in a new issue