refactor to dedicated parameters

This commit is contained in:
Michael Jerger 2023-03-14 18:06:04 +01:00
parent 7b198c7215
commit 4eeaefc1a3
3 changed files with 46 additions and 23 deletions

View file

@ -2,8 +2,8 @@ import deprecation
from .domain import Devops
from .infrastructure import ProjectRepository, FileApi
@deprecation.deprecated(deprecated_in="3.2",
details="create objects direct instead")
@deprecation.deprecated(deprecated_in="3.2", details="create objects direct instead")
def create_devops_build_config(
stage, project_root_path, module, build_dir_name="target"
):
@ -14,11 +14,13 @@ def create_devops_build_config(
"build_dir_name": build_dir_name,
}
@deprecation.deprecated(deprecated_in="3.2")
# Do not expose build to outside
def get_devops_build(project):
return project.get_property("devops_build")
@deprecation.deprecated(deprecated_in="3.2")
# TODO: Remove from here!
def get_tag_from_latest_commit():
@ -40,11 +42,13 @@ class DevopsBuild:
self.file_api = FileApi()
self.repo = ProjectRepository()
if not devops:
devops = Devops(stage = config['stage'],
project_root_path = config['project_root_path'],
module = config['module'],
devops = Devops(
stage=config["stage"],
project_root_path=config["project_root_path"],
module=config["module"],
name=project.name,
build_dir_name=config['build_dir_name'])
build_dir_name=config["build_dir_name"],
)
self.repo.set_devops(self.project, devops)
def name(self):

View file

@ -3,8 +3,8 @@ from .domain import Docker
from .application import DockerBuildService
from .devops_build import DevopsBuild, create_devops_build_config
@deprecation.deprecated(deprecated_in="3.2")
# create objects direct instead
@deprecation.deprecated(deprecated_in="3.2", details="create objects direct instead")
def create_devops_docker_build_config(
stage,
project_root_path,
@ -32,11 +32,19 @@ def create_devops_docker_build_config(
class DevopsDockerBuild(DevopsBuild):
def __init__(self, project, config):
def __init__(self, project, config: map = None, docker: Docker = None):
super().__init__(project, config)
self.docker_build_service = DockerBuildService()
docker_build = Docker(config)
self.repo. set_docker(self.project, docker_build)
if not docker:
docker = Docker(
dockerhub_user=config["dockerhub_user"],
dockerhub_password=config["dockerhub_password"],
use_package_common_files=config["use_package_common_files"],
build_commons_path=config["build_commons_path"],
docker_build_commons_dir_name=config["docker_build_commons_dir_name"],
docker_publish_tag=config["docker_publish_tag"],
)
self.repo.set_docker(self.project, docker)
def initialize_build_dir(self):
super().initialize_build_dir()

View file

@ -33,7 +33,9 @@ class DnsRecord(Validateable):
class Devops(Validateable):
def __init__(self, stage, project_root_path, module, name=None, build_dir_name="target"):
def __init__(
self, stage, project_root_path, module, name=None, build_dir_name="target"
):
self.stage = stage
self.name = name
self.project_root_path = project_root_path
@ -67,13 +69,22 @@ class Devops(Validateable):
class Docker(Validateable):
def __init__(self, config: map):
self.dockerhub_user = config["dockerhub_user"]
self.dockerhub_password = config["dockerhub_password"]
self.use_package_common_files = config["use_package_common_files"]
self.build_commons_path = config["build_commons_path"]
self.docker_build_commons_dir_name = config["docker_build_commons_dir_name"]
self.docker_publish_tag = config["docker_publish_tag"]
def __init__(
self,
dockerhub_user,
dockerhub_password,
build_dir_name="target",
use_package_common_files=True,
build_commons_path=None,
docker_build_commons_dir_name="docker",
docker_publish_tag=None,
):
self.dockerhub_user = (dockerhub_user,)
self.dockerhub_password = (dockerhub_password,)
self.use_package_common_files = (use_package_common_files,)
self.build_commons_path = (build_commons_path,)
self.docker_build_commons_dir_name = (docker_build_commons_dir_name,)
self.docker_publish_tag = (docker_publish_tag,)
def docker_build_commons_path(self):
list = [self.build_commons_path, self.docker_build_commons_dir_name]