introduce devops factory

merge-requests/12/head
Michael Jerger 1 year ago
parent a28a1b43d3
commit 481d20a14c

@ -3,6 +3,7 @@
```mermaid
classDiagram
class Devops {
<<AggregateRoot>>
stage
name
project_root_path
@ -42,8 +43,10 @@ classDiagram
current_branch
}
Devops *-- Image: spcialized_build
Devops *-- C4k: spcialized_build
Devops *-- Release: release
C4k *-- DnsRecord
Image *-- Devops
Release *-- "0..1" ReleaseContext
```

@ -1,4 +1,4 @@
from .common import Validateable, DnsRecord, Devops
from .common import Validateable, DnsRecord, Devops, DevopsFactory
from .image import Image
from .c4k import C4k
from .release import Release, ReleaseContext, ReleaseType, Version, EnvironmentKeys

@ -1,4 +1,6 @@
import deprecation
from enum import Enum
# TODO: remove logging from domain!
import logging
from typing import List
@ -70,3 +72,40 @@ class Devops(Validateable):
for key in keys:
result[key] = self.__get__(key)
return result
class BuildType(Enum):
IMAGE = 0
C4K = 1
class DevopsFactory():
def __init__(self):
pass
def build_devops(self, input) -> Devops:
build_type = BuildType[input['build_type']]
specialized_build = None
if build_type == BuildType.IMAGE:
specialized_build = Image(
dockerhub_user=input['dockerhub_user'],
dockerhub_password=input['dockerhub_password'],
docker_publish_tag=input['tag']
)
elif build_type == BuildType.C4K:
pass
devops = Devops(
stage=input['stage'],
project_root_path=input['project_root_path'],
module=input['module'],
name=input['name'],
specialized_build=specialized_build
)
# TODO: validate devops
return devops
def merge(input, autorization, context) -> dict:
pass

@ -0,0 +1,16 @@
import pytest
from src.main.python.ddadevops.domain.common import (
Devops,
DevopsFactory,
)
def test_devops_factory():
with pytest.raises(Exception):
DevopsFactory().build_devops({'build_type': 'NOTEXISTING'})
def test_devops_buildpath():
sut = Devops(
stage="test", project_root_path="../../..", module="cloud", name="meissa"
)
assert "../../../target/meissa/cloud" == sut.build_path()

@ -62,26 +62,6 @@ def test_should_validate_DnsRecord():
sut = DnsRecord("name", ipv6="1::")
assert sut.is_valid()
def test_devops_buildpath():
sut = Devops(
stage="test", project_root_path="../../..", module="cloud", name="meissa"
)
assert "../../../target/meissa/cloud" == sut.build_path()
def test_devops_build_commons_path():
devops = Devops(
stage="test", project_root_path="../../..", module="cloud", name="meissa"
)
sut = Image(
dockerhub_user="user",
dockerhub_password="password",
devops = devops,
)
assert "docker/" == sut.docker_build_commons_path()
def test_c4k_build_should_update_fqdn():
project_config = {
"stage": "test",
@ -224,3 +204,14 @@ def test_release(tmp_path):
sut.set_release_context(ReleaseContext(ReleaseType.MINOR, Version("id", [1,2,3]), "main"))
assert sut.is_valid()
def test_devops_build_commons_path():
devops = Devops(
stage="test", project_root_path="../../..", module="cloud", name="meissa"
)
sut = Image(
dockerhub_user="user",
dockerhub_password="password",
devops = devops,
)
assert "docker/" == sut.docker_build_commons_path()

Loading…
Cancel
Save