fix mypy issues
This commit is contained in:
parent
cfa05beae4
commit
32847914a7
6 changed files with 18 additions and 10 deletions
src/main/python/ddadevops
|
@ -37,7 +37,7 @@ class ImageBuildService:
|
||||||
def image(self, docker: Image):
|
def image(self, docker: Image):
|
||||||
self.docker_api.image(docker.devops.name, docker.devops.build_path())
|
self.docker_api.image(docker.devops.name, docker.devops.build_path())
|
||||||
|
|
||||||
def drun(self, docker: Devops):
|
def drun(self, docker: Image):
|
||||||
self.docker_api.drun(docker.devops.name)
|
self.docker_api.drun(docker.devops.name)
|
||||||
|
|
||||||
def dockerhub_login(self, docker: Image):
|
def dockerhub_login(self, docker: Image):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import deprecation
|
import deprecation
|
||||||
|
from typing import Optional
|
||||||
from subprocess import run, CalledProcessError
|
from subprocess import run, CalledProcessError
|
||||||
from .domain import Devops
|
from .domain import Devops
|
||||||
from .infrastructure import ProjectRepository, FileApi
|
from .infrastructure import ProjectRepository, FileApi
|
||||||
|
@ -35,11 +36,11 @@ def get_tag_from_latest_commit():
|
||||||
|
|
||||||
|
|
||||||
class DevopsBuild:
|
class DevopsBuild:
|
||||||
def __init__(self, project, config: map = None, devops: Devops = None):
|
def __init__(self, project, config: Optional[dict] = None, devops: Optional[Devops] = None):
|
||||||
self.project = project
|
self.project = project
|
||||||
self.file_api = FileApi()
|
self.file_api = FileApi()
|
||||||
self.repo = ProjectRepository()
|
self.repo = ProjectRepository()
|
||||||
if not devops:
|
if not devops and config:
|
||||||
devops = Devops(
|
devops = Devops(
|
||||||
stage=config["stage"],
|
stage=config["stage"],
|
||||||
project_root_path=config["project_root_path"],
|
project_root_path=config["project_root_path"],
|
||||||
|
@ -47,6 +48,9 @@ class DevopsBuild:
|
||||||
name=project.name,
|
name=project.name,
|
||||||
build_dir_name=config["build_dir_name"],
|
build_dir_name=config["build_dir_name"],
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
raise Exception("Build parameters could not be set!")
|
||||||
|
|
||||||
self.repo.set_devops(self.project, devops)
|
self.repo.set_devops(self.project, devops)
|
||||||
self.repo.set_build(self.project, self)
|
self.repo.set_build(self.project, self)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import deprecation
|
import deprecation
|
||||||
|
from typing import Optional
|
||||||
from .domain import Image
|
from .domain import Image
|
||||||
from .application import ImageBuildService
|
from .application import ImageBuildService
|
||||||
from .devops_build import DevopsBuild, create_devops_build_config
|
from .devops_build import DevopsBuild, create_devops_build_config
|
||||||
|
@ -32,18 +33,21 @@ def create_devops_docker_build_config(
|
||||||
|
|
||||||
|
|
||||||
class DevopsImageBuild(DevopsBuild):
|
class DevopsImageBuild(DevopsBuild):
|
||||||
def __init__(self, project, config: map = None, image: Image = None):
|
def __init__(self, project, config: Optional[dict] = None, image: Optional[Image] = None):
|
||||||
self.image_build_service = ImageBuildService()
|
self.image_build_service = ImageBuildService()
|
||||||
if not image:
|
if not image:
|
||||||
|
if not config:
|
||||||
|
raise Exception("Image parameters could not be set.")
|
||||||
|
super().__init__(project, config=config)
|
||||||
image = Image(
|
image = Image(
|
||||||
dockerhub_user=config["dockerhub_user"],
|
dockerhub_user=config["dockerhub_user"],
|
||||||
dockerhub_password=config["dockerhub_password"],
|
dockerhub_password=config["dockerhub_password"],
|
||||||
|
devops=self.repo.get_devops(project),
|
||||||
use_package_common_files=config["use_package_common_files"],
|
use_package_common_files=config["use_package_common_files"],
|
||||||
build_commons_path=config["build_commons_path"],
|
build_commons_path=config["build_commons_path"],
|
||||||
docker_build_commons_dir_name=config["docker_build_commons_dir_name"],
|
docker_build_commons_dir_name=config["docker_build_commons_dir_name"],
|
||||||
docker_publish_tag=config["docker_publish_tag"],
|
docker_publish_tag=config["docker_publish_tag"],
|
||||||
)
|
)
|
||||||
super().__init__(project, config=config)
|
|
||||||
else:
|
else:
|
||||||
super().__init__(project, devops=image.devops)
|
super().__init__(project, devops=image.devops)
|
||||||
self.repo.set_docker(self.project, image)
|
self.repo.set_docker(self.project, image)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import deprecation
|
from typing import List, Optional
|
||||||
from typing import List
|
|
||||||
from .common import (
|
from .common import (
|
||||||
Validateable,
|
Validateable,
|
||||||
DnsRecord,
|
DnsRecord,
|
||||||
|
@ -7,7 +6,7 @@ from .common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
class C4k(Validateable):
|
class C4k(Validateable):
|
||||||
def __init__(self, config: map):
|
def __init__(self, config: dict):
|
||||||
tmp_executabel_name = config["C4kMixin"]["executabel_name"]
|
tmp_executabel_name = config["C4kMixin"]["executabel_name"]
|
||||||
if not tmp_executabel_name:
|
if not tmp_executabel_name:
|
||||||
tmp_executabel_name = config["module"]
|
tmp_executabel_name = config["module"]
|
||||||
|
@ -17,7 +16,7 @@ class C4k(Validateable):
|
||||||
tmp = self.c4k_mixin_config["mon-cfg"]
|
tmp = self.c4k_mixin_config["mon-cfg"]
|
||||||
tmp.update({"cluster-name": config["module"], "cluster-stage": config["stage"]})
|
tmp.update({"cluster-name": config["module"], "cluster-stage": config["stage"]})
|
||||||
self.c4k_mixin_config.update({"mon-cfg": tmp})
|
self.c4k_mixin_config.update({"mon-cfg": tmp})
|
||||||
self.dns_record = None
|
self.dns_record: Optional[DnsRecord] = None
|
||||||
|
|
||||||
# TODO: these functions should be located at TerraformBuild later on.
|
# TODO: these functions should be located at TerraformBuild later on.
|
||||||
def update_runtime_config(self, dns_record: DnsRecord):
|
def update_runtime_config(self, dns_record: DnsRecord):
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from typing import Optional
|
||||||
from .common import (
|
from .common import (
|
||||||
filter_none,
|
filter_none,
|
||||||
Validateable,
|
Validateable,
|
||||||
|
|
|
@ -111,7 +111,7 @@ class ImageApi:
|
||||||
|
|
||||||
|
|
||||||
class ExecutionApi:
|
class ExecutionApi:
|
||||||
def execute(command: str, dry_run=False):
|
def execute(self, command: str, dry_run=False):
|
||||||
output = ""
|
output = ""
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(command)
|
print(command)
|
||||||
|
|
Loading…
Add table
Reference in a new issue