This commit is contained in:
Michael Jerger 2023-04-28 18:13:58 +02:00
parent e501525db2
commit 2add0a76a2
3 changed files with 28 additions and 27 deletions

View file

@ -1,20 +1,18 @@
import deprecation import deprecation
from enum import Enum from enum import Enum
from typing import List from typing import List
from .common import ( from .common import Devops, BuildType
Devops,
BuildType
)
from .image import ( from .image import (
Image, Image,
) )
class DevopsFactory():
class DevopsFactory:
def __init__(self): def __init__(self):
pass pass
def build_devops(self, input) -> Devops: def build_devops(self, input) -> Devops:
build_type = BuildType[input['build_type']] build_type = BuildType[input["build_type"]]
specialized_build = None specialized_build = None
if build_type == BuildType.IMAGE: if build_type == BuildType.IMAGE:
specialized_build = Image(input) specialized_build = Image(input)
@ -29,4 +27,3 @@ class DevopsFactory():
def merge(input, autorization, context) -> dict: def merge(input, autorization, context) -> dict:
pass pass

View file

@ -1,22 +1,25 @@
from typing import (Optional, List) from typing import Optional, List
from .common import ( from .common import (
filter_none, filter_none,
Validateable, Validateable,
Devops, Devops,
) )
class Image(Validateable): class Image(Validateable):
def __init__( def __init__(
self, self,
input, input,
): ):
self.dockerhub_user=input.get('dockerhub_user') self.dockerhub_user = input.get("dockerhub_user")
self.dockerhub_password=input.get('dockerhub_password') self.dockerhub_password = input.get("dockerhub_password")
self.docker_publish_tag=input.get('docker_publish_tag') self.docker_publish_tag = input.get("docker_publish_tag")
self.build_commons_path = input.get('build_commons_path') self.build_commons_path = input.get("build_commons_path")
self.docker_publish_tag = input.get('docker_publish_tag') self.docker_publish_tag = input.get("docker_publish_tag")
self.use_package_common_files = input.get('use_package_common_files', True) self.use_package_common_files = input.get("use_package_common_files", True)
self.docker_build_commons_dir_name = input.get('docker_build_commons_dir_name', 'docker') self.docker_build_commons_dir_name = input.get(
"docker_build_commons_dir_name", "docker"
)
def validate(self) -> List[str]: def validate(self) -> List[str]:
result = [] result = []

View file

@ -1,16 +1,17 @@
from src.main.python.ddadevops.domain import ( from src.main.python.ddadevops.domain import DevopsFactory, Devops
DevopsFactory, Devops
)
def build_devops(overrides: dict) -> Devops: def build_devops(overrides: dict) -> Devops:
default = {'build_type': 'IMAGE', default = {
'stage': 'test', "build_type": "IMAGE",
'project_root_path': "../../..", "stage": "test",
'name': 'mybuild', "project_root_path": "../../..",
'module': 'test_image', "name": "mybuild",
'dockerhub_user': 'dockerhub_user', "module": "test_image",
'dockerhub_password': 'dockerhub_password', "dockerhub_user": "dockerhub_user",
'docker_image_tag': 'docker_image_tag',} "dockerhub_password": "dockerhub_password",
"docker_image_tag": "docker_image_tag",
}
input = default.copy() input = default.copy()
input.update(overrides) input.update(overrides)
return DevopsFactory().build_devops(input) return DevopsFactory().build_devops(input)