From 771ffe5229fbcdaef15ba76ee4c4ef821397f55d Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 14 Jul 2023 12:42:46 +0200 Subject: [PATCH] mv domain logic to domain --- .../application/image_build_service.py | 18 ++++++++++++------ .../ddadevops/infrastructure/infrastructure.py | 13 +++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/python/ddadevops/application/image_build_service.py b/src/main/python/ddadevops/application/image_build_service.py index 03ea089..59117da 100644 --- a/src/main/python/ddadevops/application/image_build_service.py +++ b/src/main/python/ddadevops/application/image_build_service.py @@ -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): diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index 89351d0..14cc14c 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -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):