refactoring: rename DockerBuild -> Docker

This commit is contained in:
Michael Jerger 2023-03-14 12:22:05 +01:00
parent 571828f6cd
commit 5ff4a4c9bb
6 changed files with 21 additions and 19 deletions

View file

@ -10,6 +10,8 @@ classDiagram
build_dir_name
}
class Docker
class C4kBuild {
executabel_name
c4k_mixin_config

View file

@ -19,7 +19,7 @@ from .devops_terraform_build import DevopsTerraformBuild, create_devops_terrafor
from .devops_build import DevopsBuild, create_devops_build_config, get_devops_build, get_tag_from_latest_commit
from .credential import gopass_password_from_path, gopass_field_from_path
from .domain import Validateable, DnsRecord, Devops, DockerBuild, C4kBuild
from .domain import Validateable, DnsRecord, Devops, Docker, C4kBuild
from .application import DockerBuildService
from .infrastructure import ProjectRepository, ResourceApi, FileApi, DockerApi, ExecutionApi

View file

@ -1,4 +1,4 @@
from .domain import Devops, DockerBuild, C4kBuild
from .domain import Devops, Docker, C4kBuild
from .infrastructure import FileApi, ResourceApi, DockerApi, ExecutionApi
@ -8,21 +8,21 @@ class DockerBuildService:
self.resource_api = ResourceApi()
self.docker_api = DockerApi()
def __copy_build_resource_file_from_package__(self, build: DockerBuild):
def __copy_build_resource_file_from_package__(self, build: Docker):
data = self.resource_api.read_resource(
"src/main/resources/docker/" + build.name
)
self.file_api.write_data_to_file(build.build_path() + "/" + build.name, data)
def __copy_build_resources_from_package__(self, build: DockerBuild):
def __copy_build_resources_from_package__(self, build: Docker):
self.__copy_build_resource_file_from_package__(
"image/resources/install_functions.sh"
)
def __copy_build_resources_from_dir__(self, build: DockerBuild):
def __copy_build_resources_from_dir__(self, build: Docker):
self.file_api.cp_force(build.docker_build_commons_path(), build.build_path())
def initialize_build_dir(self, build: Devops, docker_build: DockerBuild):
def initialize_build_dir(self, build: Devops, docker_build: Docker):
build_path = build.build_path()
self.file_api.clean_dir(f"{build_path}/image/resources")
if docker_build.use_package_common_files:
@ -35,13 +35,13 @@ class DockerBuildService:
def image(self, build: Devops):
self.docker_api.image(build.name(), build.build_path())
def drun(self, build: DockerBuild):
def drun(self, build: Docker):
self.docker_api.drun(build.name())
def dockerhub_login(self, docker_build: DockerBuild):
def dockerhub_login(self, docker_build: Docker):
self.docker_api.dockerhub_login(docker_build.dockerhub_user, docker_build.dockerhub_password)
def dockerhub_publish(self, build: Devops, docker_build: DockerBuild):
def dockerhub_publish(self, build: Devops, docker_build: Docker):
self.docker_api.dockerhub_publish(
build.name(), docker_build.dockerhub_user, docker_build.docker_publish_tag
)

View file

@ -1,5 +1,5 @@
import deprecation
from .domain import DockerBuild
from .domain import Docker
from .application import DockerBuildService
from .devops_build import DevopsBuild, create_devops_build_config
@ -35,13 +35,13 @@ class DevopsDockerBuild(DevopsBuild):
def __init__(self, project, config):
super().__init__(project, config)
self.docker_build_service = DockerBuildService()
docker_build = DockerBuild(config)
self.repo.set_docker_build(self.project, docker_build)
docker_build = Docker(config)
self.repo. set_docker(self.project, docker_build)
def initialize_build_dir(self):
super().initialize_build_dir()
build = self.repo.get_devops(self.project)
docker_build = self.repo.get_docker_build(self.project)
docker_build = self.repo. get_docker(self.project)
self.docker_build_service.initialize_build_dir(build, docker_build)
def image(self):
@ -53,12 +53,12 @@ class DevopsDockerBuild(DevopsBuild):
self.docker_build_service.drun(build)
def dockerhub_login(self):
docker_build = self.repo.get_docker_build(self.project)
docker_build = self.repo. get_docker(self.project)
self.docker_build_service.dockerhub_login(docker_build)
def dockerhub_publish(self):
build = self.repo.get_devops(self.project)
docker_build = self.repo.get_docker_build(self.project)
docker_build = self.repo. get_docker(self.project)
self.docker_build_service.dockerhub_publish(build, docker_build)
def test(self):

View file

@ -64,7 +64,7 @@ class Devops(Validateable):
return result
class DockerBuild(Validateable):
class Docker(Validateable):
def __init__(self, config: map):
self.dockerhub_user = config["dockerhub_user"]
self.dockerhub_password = config["dockerhub_password"]

View file

@ -3,7 +3,7 @@ from sys import stdout
from pkg_resources import resource_string
from os import chmod
import yaml
from .domain import Devops, DockerBuild, C4kBuild
from .domain import Devops, Docker, C4kBuild
from .python_util import execute
@ -14,10 +14,10 @@ class ProjectRepository:
def set_devops(self, project, build: Devops):
project.set_property("build", build)
def get_docker_build(self, project) -> DockerBuild:
def get_docker(self, project) -> Docker:
return project.get_property("docker_build")
def set_docker_build(self, project, build: DockerBuild):
def set_docker(self, project, build: Docker):
project.set_property("docker_build", build)
def get_c4k_build(self, project) -> C4kBuild: