refactor to dedicated parameters
This commit is contained in:
parent
7b198c7215
commit
4eeaefc1a3
3 changed files with 46 additions and 23 deletions
|
@ -2,8 +2,8 @@ import deprecation
|
||||||
from .domain import Devops
|
from .domain import Devops
|
||||||
from .infrastructure import ProjectRepository, FileApi
|
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(
|
def create_devops_build_config(
|
||||||
stage, project_root_path, module, build_dir_name="target"
|
stage, project_root_path, module, build_dir_name="target"
|
||||||
):
|
):
|
||||||
|
@ -14,11 +14,13 @@ def create_devops_build_config(
|
||||||
"build_dir_name": build_dir_name,
|
"build_dir_name": build_dir_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@deprecation.deprecated(deprecated_in="3.2")
|
@deprecation.deprecated(deprecated_in="3.2")
|
||||||
# Do not expose build to outside
|
# Do not expose build to outside
|
||||||
def get_devops_build(project):
|
def get_devops_build(project):
|
||||||
return project.get_property("devops_build")
|
return project.get_property("devops_build")
|
||||||
|
|
||||||
|
|
||||||
@deprecation.deprecated(deprecated_in="3.2")
|
@deprecation.deprecated(deprecated_in="3.2")
|
||||||
# TODO: Remove from here!
|
# TODO: Remove from here!
|
||||||
def get_tag_from_latest_commit():
|
def get_tag_from_latest_commit():
|
||||||
|
@ -40,11 +42,13 @@ class DevopsBuild:
|
||||||
self.file_api = FileApi()
|
self.file_api = FileApi()
|
||||||
self.repo = ProjectRepository()
|
self.repo = ProjectRepository()
|
||||||
if not devops:
|
if not devops:
|
||||||
devops = Devops(stage = config['stage'],
|
devops = Devops(
|
||||||
project_root_path = config['project_root_path'],
|
stage=config["stage"],
|
||||||
module = config['module'],
|
project_root_path=config["project_root_path"],
|
||||||
|
module=config["module"],
|
||||||
name=project.name,
|
name=project.name,
|
||||||
build_dir_name=config['build_dir_name'])
|
build_dir_name=config["build_dir_name"],
|
||||||
|
)
|
||||||
self.repo.set_devops(self.project, devops)
|
self.repo.set_devops(self.project, devops)
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -3,8 +3,8 @@ from .domain import Docker
|
||||||
from .application import DockerBuildService
|
from .application import DockerBuildService
|
||||||
from .devops_build import DevopsBuild, create_devops_build_config
|
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(
|
def create_devops_docker_build_config(
|
||||||
stage,
|
stage,
|
||||||
project_root_path,
|
project_root_path,
|
||||||
|
@ -32,11 +32,19 @@ def create_devops_docker_build_config(
|
||||||
|
|
||||||
|
|
||||||
class DevopsDockerBuild(DevopsBuild):
|
class DevopsDockerBuild(DevopsBuild):
|
||||||
def __init__(self, project, config):
|
def __init__(self, project, config: map = None, docker: Docker = None):
|
||||||
super().__init__(project, config)
|
super().__init__(project, config)
|
||||||
self.docker_build_service = DockerBuildService()
|
self.docker_build_service = DockerBuildService()
|
||||||
docker_build = Docker(config)
|
if not docker:
|
||||||
self.repo. set_docker(self.project, docker_build)
|
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):
|
def initialize_build_dir(self):
|
||||||
super().initialize_build_dir()
|
super().initialize_build_dir()
|
||||||
|
|
|
@ -33,7 +33,9 @@ class DnsRecord(Validateable):
|
||||||
|
|
||||||
|
|
||||||
class Devops(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.stage = stage
|
||||||
self.name = name
|
self.name = name
|
||||||
self.project_root_path = project_root_path
|
self.project_root_path = project_root_path
|
||||||
|
@ -67,13 +69,22 @@ class Devops(Validateable):
|
||||||
|
|
||||||
|
|
||||||
class Docker(Validateable):
|
class Docker(Validateable):
|
||||||
def __init__(self, config: map):
|
def __init__(
|
||||||
self.dockerhub_user = config["dockerhub_user"]
|
self,
|
||||||
self.dockerhub_password = config["dockerhub_password"]
|
dockerhub_user,
|
||||||
self.use_package_common_files = config["use_package_common_files"]
|
dockerhub_password,
|
||||||
self.build_commons_path = config["build_commons_path"]
|
build_dir_name="target",
|
||||||
self.docker_build_commons_dir_name = config["docker_build_commons_dir_name"]
|
use_package_common_files=True,
|
||||||
self.docker_publish_tag = config["docker_publish_tag"]
|
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):
|
def docker_build_commons_path(self):
|
||||||
list = [self.build_commons_path, self.docker_build_commons_dir_name]
|
list = [self.build_commons_path, self.docker_build_commons_dir_name]
|
||||||
|
|
Loading…
Reference in a new issue