|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import deprecation
|
|
|
|
|
from enum import Enum
|
|
|
|
|
from typing import List
|
|
|
|
|
from typing import List, TypedDict
|
|
|
|
|
import logging
|
|
|
|
|
import deprecation
|
|
|
|
|
|
|
|
|
@ -12,11 +12,16 @@ class BuildType(Enum):
|
|
|
|
|
C4K = 1
|
|
|
|
|
|
|
|
|
|
class Validateable:
|
|
|
|
|
def __validate_is_not_none__(self, field_name: str) -> List[str]:
|
|
|
|
|
value = self.__dict__[field_name]
|
|
|
|
|
if value is None:
|
|
|
|
|
return [f"Field '{field_name}' must not be None."]
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
def __validate_is_not_empty__(self, field_name: str) -> List[str]:
|
|
|
|
|
value = self.__dict__[field_name]
|
|
|
|
|
if value is None or value == "":
|
|
|
|
|
return [f"Field '{field_name}' must not be empty."]
|
|
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
def validate(self) -> List[str]:
|
|
|
|
@ -45,14 +50,13 @@ class DnsRecord(Validateable):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Devops(Validateable):
|
|
|
|
|
def __init__(self, input: dict, build_type: BuildType, specialized_build: Validateable):
|
|
|
|
|
def __init__(self, input: dict, specialized_builds: dict[BuildType, Validateable]):
|
|
|
|
|
self.stage = input.get('stage')
|
|
|
|
|
self.project_root_path = input.get('project_root_path')
|
|
|
|
|
self.module = input.get('module')
|
|
|
|
|
self.name = input.get('name', self.module)
|
|
|
|
|
self.build_dir_name = input.get('build_dir_name', 'target')
|
|
|
|
|
self.build_type = build_type
|
|
|
|
|
self.specialized_build=specialized_build
|
|
|
|
|
self.specialized_builds=specialized_builds
|
|
|
|
|
|
|
|
|
|
def build_path(self):
|
|
|
|
|
path = [self.project_root_path, self.build_dir_name, self.name, self.module]
|
|
|
|
@ -63,9 +67,10 @@ class Devops(Validateable):
|
|
|
|
|
result += self.__validate_is_not_empty__("stage")
|
|
|
|
|
result += self.__validate_is_not_empty__("project_root_path")
|
|
|
|
|
result += self.__validate_is_not_empty__("module")
|
|
|
|
|
result += self.__validate_is_not_empty__("specialized_build")
|
|
|
|
|
if self.specialized_build:
|
|
|
|
|
result += self.specialized_build.validate()
|
|
|
|
|
result += self.__validate_is_not_none__("specialized_builds")
|
|
|
|
|
if self.specialized_builds:
|
|
|
|
|
for build in self.specialized_builds:
|
|
|
|
|
result += self.specialized_builds[build].validate()
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def __put__(self, key, value):
|
|
|
|
|