refactor to domain-object creation by dict
parent
481d20a14c
commit
79de907396
@ -1,4 +1,5 @@
|
||||
from .common import Validateable, DnsRecord, Devops, DevopsFactory
|
||||
from .common import Validateable, DnsRecord, Devops
|
||||
from .devops_factory import DevopsFactory
|
||||
from .image import Image
|
||||
from .c4k import C4k
|
||||
from .release import Release, ReleaseContext, ReleaseType, Version, EnvironmentKeys
|
||||
|
@ -0,0 +1,32 @@
|
||||
import deprecation
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
from .common import (
|
||||
Devops,
|
||||
BuildType
|
||||
)
|
||||
from .image import (
|
||||
Image,
|
||||
)
|
||||
|
||||
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(input)
|
||||
elif build_type == BuildType.C4K:
|
||||
pass
|
||||
|
||||
devops = Devops(input, specialized_build=specialized_build)
|
||||
|
||||
# TODO: validate devops
|
||||
|
||||
return devops
|
||||
|
||||
def merge(input, autorization, context) -> dict:
|
||||
pass
|
||||
|
@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
from src.main.python.ddadevops.domain.devops_factory import (
|
||||
DevopsFactory,
|
||||
)
|
||||
|
||||
def test_devops_factory():
|
||||
with pytest.raises(Exception):
|
||||
DevopsFactory().build_devops(
|
||||
{'build_type': 'NOTEXISTING'}
|
||||
)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
DevopsFactory().build_devops(
|
||||
{'build_type': 'IMAGE'}
|
||||
)
|
||||
|
||||
sut = DevopsFactory().build_devops(
|
||||
{'build_type': 'IMAGE',
|
||||
'stage': 'test',
|
||||
'project_root_path': "../../..",
|
||||
'name': 'mybuild',
|
||||
'module': 'test_image',
|
||||
'dockerhub_user': 'dockerhub_user',
|
||||
'dockerhub_password': 'dockerhub_password',
|
||||
'docker_image_tag': 'docker_image_tag',}
|
||||
)
|
||||
assert sut != None
|
@ -0,0 +1,9 @@
|
||||
from src.main.python.ddadevops.domain import (
|
||||
DevopsFactory, Devops
|
||||
)
|
||||
|
||||
def build_devops(overrides: dict) -> Devops:
|
||||
default = {}
|
||||
input = default.copy()
|
||||
input.update(overrides)
|
||||
return DevopsFactory().build_devops(input)
|
Loading…
Reference in New Issue