refactoring: rename Build -> Devops
This commit is contained in:
parent
dd85b7b95b
commit
0717b0b361
11 changed files with 40 additions and 58 deletions
|
@ -92,19 +92,3 @@ classDiagram
|
||||||
DevopsBuild <|-- C4kMixin
|
DevopsBuild <|-- C4kMixin
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Build Frontend with application and domain
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
classDiagram
|
|
||||||
DevopsBuild <|-- DevopsDockerBuild
|
|
||||||
DevopsBuild <|-- DevopsTerraformBuild
|
|
||||||
|
|
||||||
DevopsBuild <|-- C4kMixin
|
|
||||||
|
|
||||||
DevopsBuild *-- BuildService
|
|
||||||
DevopsDockerBuild *-- DockerBuildService
|
|
||||||
C4kMixin *-- C4kBuildService
|
|
||||||
```
|
|
||||||
|
|
||||||
# Domain
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Build Frontend with application and domain
|
# Devops Frontend with application and domain
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
classDiagram
|
classDiagram
|
||||||
|
@ -8,11 +8,11 @@ classDiagram
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectRepository {
|
class ProjectRepository {
|
||||||
get_build(project): Build
|
get_devops(project): Devops
|
||||||
set_build(project, build)
|
set_devops(project, build)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Build
|
class Devops
|
||||||
|
|
||||||
class BuildService {
|
class BuildService {
|
||||||
do_sth(project, build)
|
do_sth(project, build)
|
||||||
|
@ -34,8 +34,8 @@ sequenceDiagram
|
||||||
MyBuild ->> DevOpsBuild: create_config
|
MyBuild ->> DevOpsBuild: create_config
|
||||||
MyBuild ->> DevOpsBuild: __init__(project, config)
|
MyBuild ->> DevOpsBuild: __init__(project, config)
|
||||||
activate DevOpsBuild
|
activate DevOpsBuild
|
||||||
DevOpsBuild ->> Build: __init__
|
DevOpsBuild ->> Devops: __init__
|
||||||
DevOpsBuild ->> ProjectRepository: set_build(build)
|
DevOpsBuild ->> ProjectRepository: set_devops(build)
|
||||||
deactivate DevOpsBuild
|
deactivate DevOpsBuild
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ sequenceDiagram
|
||||||
activate DevOpsBuild
|
activate DevOpsBuild
|
||||||
DevOpsBuild ->> BuildService: do_sth(project)
|
DevOpsBuild ->> BuildService: do_sth(project)
|
||||||
activate BuildService
|
activate BuildService
|
||||||
BuildService ->> ProjectRepository: get_build
|
BuildService ->> ProjectRepository: get_devops
|
||||||
BuildService ->> BuildService: do_some_complicated_stuff(build)
|
BuildService ->> BuildService: do_some_complicated_stuff(build)
|
||||||
deactivate BuildService
|
deactivate BuildService
|
||||||
deactivate DevOpsBuild
|
deactivate DevOpsBuild
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
classDiagram
|
classDiagram
|
||||||
class Build {
|
class Devops {
|
||||||
stage
|
stage
|
||||||
name
|
name
|
||||||
project_root_path
|
project_root_path
|
||||||
|
@ -31,10 +31,8 @@ classDiagram
|
||||||
```mermaid
|
```mermaid
|
||||||
classDiagram
|
classDiagram
|
||||||
class ProjectRepository {
|
class ProjectRepository {
|
||||||
get_build(project): Build
|
get_devops(project): Devops
|
||||||
set_build(project, build)
|
set_devops(project, build)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
|
@ -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 .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 .credential import gopass_password_from_path, gopass_field_from_path
|
||||||
|
|
||||||
from .domain import Validateable, DnsRecord, Build, DockerBuild, C4kBuild
|
from .domain import Validateable, DnsRecord, Devops, DockerBuild, C4kBuild
|
||||||
from .application import DockerBuildService
|
from .application import DockerBuildService
|
||||||
from .infrastructure import ProjectRepository, ResourceApi, FileApi, DockerApi, ExecutionApi
|
from .infrastructure import ProjectRepository, ResourceApi, FileApi, DockerApi, ExecutionApi
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .domain import Build, DockerBuild, C4kBuild
|
from .domain import Devops, DockerBuild, C4kBuild
|
||||||
from .infrastructure import FileApi, ResourceApi, DockerApi, ExecutionApi
|
from .infrastructure import FileApi, ResourceApi, DockerApi, ExecutionApi
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class DockerBuildService:
|
||||||
def __copy_build_resources_from_dir__(self, build: DockerBuild):
|
def __copy_build_resources_from_dir__(self, build: DockerBuild):
|
||||||
self.file_api.cp_force(build.docker_build_commons_path(), build.build_path())
|
self.file_api.cp_force(build.docker_build_commons_path(), build.build_path())
|
||||||
|
|
||||||
def initialize_build_dir(self, build: Build, docker_build: DockerBuild):
|
def initialize_build_dir(self, build: Devops, docker_build: DockerBuild):
|
||||||
build_path = build.build_path()
|
build_path = build.build_path()
|
||||||
self.file_api.clean_dir(f"{build_path}/image/resources")
|
self.file_api.clean_dir(f"{build_path}/image/resources")
|
||||||
if docker_build.use_package_common_files:
|
if docker_build.use_package_common_files:
|
||||||
|
@ -32,7 +32,7 @@ class DockerBuildService:
|
||||||
self.file_api.cp_recursive("image", build_path)
|
self.file_api.cp_recursive("image", build_path)
|
||||||
self.file_api.cp_recursive("test", build_path)
|
self.file_api.cp_recursive("test", build_path)
|
||||||
|
|
||||||
def image(self, build: Build):
|
def image(self, build: Devops):
|
||||||
self.docker_api.image(build.name(), build.build_path())
|
self.docker_api.image(build.name(), build.build_path())
|
||||||
|
|
||||||
def drun(self, build: DockerBuild):
|
def drun(self, build: DockerBuild):
|
||||||
|
@ -41,10 +41,10 @@ class DockerBuildService:
|
||||||
def dockerhub_login(self, docker_build: DockerBuild):
|
def dockerhub_login(self, docker_build: DockerBuild):
|
||||||
self.docker_api.dockerhub_login(docker_build.dockerhub_user, docker_build.dockerhub_password)
|
self.docker_api.dockerhub_login(docker_build.dockerhub_user, docker_build.dockerhub_password)
|
||||||
|
|
||||||
def dockerhub_publish(self, build: Build, docker_build: DockerBuild):
|
def dockerhub_publish(self, build: Devops, docker_build: DockerBuild):
|
||||||
self.docker_api.dockerhub_publish(
|
self.docker_api.dockerhub_publish(
|
||||||
build.name(), docker_build.dockerhub_user, docker_build.docker_publish_tag
|
build.name(), docker_build.dockerhub_user, docker_build.docker_publish_tag
|
||||||
)
|
)
|
||||||
|
|
||||||
def test(self, build: Build):
|
def test(self, build: Devops):
|
||||||
self.docker_api.test(build.name(), build.build_path())
|
self.docker_api.test(build.name(), build.build_path())
|
||||||
|
|
|
@ -58,18 +58,18 @@ class C4kMixin(DevopsBuild):
|
||||||
self.repo.set_c4k_build(self.project, c4k_build)
|
self.repo.set_c4k_build(self.project, c4k_build)
|
||||||
|
|
||||||
def write_c4k_config(self):
|
def write_c4k_config(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
c4k_build = self.repo.get_c4k_build(self.project)
|
c4k_build = self.repo.get_c4k_build(self.project)
|
||||||
path = build.build_path() + "/out_c4k_config.yaml"
|
path = build.build_path() + "/out_c4k_config.yaml"
|
||||||
self.file_api.write_yaml_to_file(path, c4k_build.config())
|
self.file_api.write_yaml_to_file(path, c4k_build.config())
|
||||||
|
|
||||||
def write_c4k_auth(self):
|
def write_c4k_auth(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
c4k_build = self.repo.get_c4k_build(self.project)
|
c4k_build = self.repo.get_c4k_build(self.project)
|
||||||
path = build.build_path() + "/out_c4k_auth.yaml"
|
path = build.build_path() + "/out_c4k_auth.yaml"
|
||||||
self.file_api.write_yaml_to_file(path, c4k_build.c4k_mixin_auth)
|
self.file_api.write_yaml_to_file(path, c4k_build.c4k_mixin_auth)
|
||||||
|
|
||||||
def c4k_apply(self, dry_run=False):
|
def c4k_apply(self, dry_run=False):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
c4k_build = self.repo.get_c4k_build(self.project)
|
c4k_build = self.repo.get_c4k_build(self.project)
|
||||||
return self.execution_api.execute(c4k_build.command(build), dry_run)
|
return self.execution_api.execute(c4k_build.command(build), dry_run)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import deprecation
|
import deprecation
|
||||||
from .domain import Build
|
from .domain import Devops
|
||||||
from .infrastructure import ProjectRepository, FileApi
|
from .infrastructure import ProjectRepository, FileApi
|
||||||
|
|
||||||
@deprecation.deprecated(deprecated_in="3.2")
|
@deprecation.deprecated(deprecated_in="3.2")
|
||||||
|
@ -40,17 +40,17 @@ class DevopsBuild:
|
||||||
self.file_api = FileApi()
|
self.file_api = FileApi()
|
||||||
self.repo = ProjectRepository()
|
self.repo = ProjectRepository()
|
||||||
config.update({"name": project.name})
|
config.update({"name": project.name})
|
||||||
build = Build(config)
|
build = Devops(config)
|
||||||
self.repo.set_build(self.project, build)
|
self.repo.set_devops(self.project, build)
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
return build.name
|
return build.name
|
||||||
|
|
||||||
def build_path(self):
|
def build_path(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
return build.build_path()
|
return build.build_path()
|
||||||
|
|
||||||
def initialize_build_dir(self):
|
def initialize_build_dir(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
self.file_api.clean_dir(build.build_path())
|
self.file_api.clean_dir(build.build_path())
|
||||||
|
|
|
@ -39,16 +39,16 @@ class DevopsDockerBuild(DevopsBuild):
|
||||||
|
|
||||||
def initialize_build_dir(self):
|
def initialize_build_dir(self):
|
||||||
super().initialize_build_dir()
|
super().initialize_build_dir()
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
docker_build = self.repo.get_docker_build(self.project)
|
docker_build = self.repo.get_docker_build(self.project)
|
||||||
self.docker_build_service.initialize_build_dir(build, docker_build)
|
self.docker_build_service.initialize_build_dir(build, docker_build)
|
||||||
|
|
||||||
def image(self):
|
def image(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
self.docker_build_service.image(build)
|
self.docker_build_service.image(build)
|
||||||
|
|
||||||
def drun(self):
|
def drun(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
self.docker_build_service.drun(build)
|
self.docker_build_service.drun(build)
|
||||||
|
|
||||||
def dockerhub_login(self):
|
def dockerhub_login(self):
|
||||||
|
@ -56,10 +56,10 @@ class DevopsDockerBuild(DevopsBuild):
|
||||||
self.docker_build_service.dockerhub_login(docker_build)
|
self.docker_build_service.dockerhub_login(docker_build)
|
||||||
|
|
||||||
def dockerhub_publish(self):
|
def dockerhub_publish(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
docker_build = self.repo.get_docker_build(self.project)
|
docker_build = self.repo.get_docker_build(self.project)
|
||||||
self.docker_build_service.dockerhub_publish(build, docker_build)
|
self.docker_build_service.dockerhub_publish(build, docker_build)
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
build = self.repo.get_build(self.project)
|
build = self.repo.get_devops(self.project)
|
||||||
self.test.dockerhub_publish(build)
|
self.test.dockerhub_publish(build)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class DnsRecord(Validateable):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Build(Validateable):
|
class Devops(Validateable):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.stage = config["stage"]
|
self.stage = config["stage"]
|
||||||
self.name = config["name"]
|
self.name = config["name"]
|
||||||
|
@ -107,7 +107,7 @@ class C4kBuild(Validateable):
|
||||||
self.c4k_mixin_config.update({"fqdn": fqdn})
|
self.c4k_mixin_config.update({"fqdn": fqdn})
|
||||||
return self.c4k_mixin_config
|
return self.c4k_mixin_config
|
||||||
|
|
||||||
def command(self, build: Build):
|
def command(self, build: Devops):
|
||||||
module = build.module
|
module = build.module
|
||||||
build_path = build.build_path()
|
build_path = build.build_path()
|
||||||
config_path = f"{build_path}/out_c4k_config.yaml"
|
config_path = f"{build_path}/out_c4k_config.yaml"
|
||||||
|
|
|
@ -3,15 +3,15 @@ from sys import stdout
|
||||||
from pkg_resources import resource_string
|
from pkg_resources import resource_string
|
||||||
from os import chmod
|
from os import chmod
|
||||||
import yaml
|
import yaml
|
||||||
from .domain import Build, DockerBuild, C4kBuild
|
from .domain import Devops, DockerBuild, C4kBuild
|
||||||
from .python_util import execute
|
from .python_util import execute
|
||||||
|
|
||||||
|
|
||||||
class ProjectRepository:
|
class ProjectRepository:
|
||||||
def get_build(self, project) -> Build:
|
def get_devops(self, project) -> Devops:
|
||||||
return project.get_property("build")
|
return project.get_property("build")
|
||||||
|
|
||||||
def set_build(self, project, build: Build):
|
def set_devops(self, project, build: Devops):
|
||||||
project.set_property("build", build)
|
project.set_property("build", build)
|
||||||
|
|
||||||
def get_docker_build(self, project) -> DockerBuild:
|
def get_docker_build(self, project) -> DockerBuild:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from pybuilder.core import Project
|
from pybuilder.core import Project
|
||||||
from src.main.python.ddadevops.domain import Validateable, DnsRecord, C4kBuild, Build
|
from src.main.python.ddadevops.domain import Validateable, DnsRecord, C4kBuild, Devops
|
||||||
from src.main.python.ddadevops.c4k_mixin import add_c4k_mixin_config
|
from src.main.python.ddadevops.c4k_mixin import add_c4k_mixin_config
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ def test_c4k_build_should_update_fqdn(tmp_path):
|
||||||
grafana_cloud_user="user",
|
grafana_cloud_user="user",
|
||||||
grafana_cloud_password="password",
|
grafana_cloud_password="password",
|
||||||
)
|
)
|
||||||
build = Build(project_config)
|
build = Devops(project_config)
|
||||||
sut = C4kBuild(project_config)
|
sut = C4kBuild(project_config)
|
||||||
sut.update_runtime_config(DnsRecord("test.de", ipv6="1::"))
|
sut.update_runtime_config(DnsRecord("test.de", ipv6="1::"))
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ def test_c4k_build_should_calculate_command(tmp_path):
|
||||||
grafana_cloud_user="user",
|
grafana_cloud_user="user",
|
||||||
grafana_cloud_password="password",
|
grafana_cloud_password="password",
|
||||||
)
|
)
|
||||||
build = Build(project_config)
|
build = Devops(project_config)
|
||||||
sut = C4kBuild(project_config)
|
sut = C4kBuild(project_config)
|
||||||
assert (
|
assert (
|
||||||
"c4k-module-standalone.jar "
|
"c4k-module-standalone.jar "
|
||||||
|
@ -142,7 +142,7 @@ def test_c4k_build_should_calculate_command(tmp_path):
|
||||||
grafana_cloud_user="user",
|
grafana_cloud_user="user",
|
||||||
grafana_cloud_password="password",
|
grafana_cloud_password="password",
|
||||||
)
|
)
|
||||||
build = Build(project_config)
|
build = Devops(project_config)
|
||||||
sut = C4kBuild(project_config)
|
sut = C4kBuild(project_config)
|
||||||
assert (
|
assert (
|
||||||
"c4k-executabel_name-standalone.jar "
|
"c4k-executabel_name-standalone.jar "
|
||||||
|
|
Loading…
Reference in a new issue