|
|
|
@ -18,6 +18,20 @@ class Validateable:
|
|
|
|
|
return len(self.validate()) < 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DnsRecord(Validateable):
|
|
|
|
|
def __init__(self, fqdn, ipv4=None, ipv6=None):
|
|
|
|
|
self.fqdn = fqdn
|
|
|
|
|
self.ipv4 = ipv4
|
|
|
|
|
self.ipv6 = ipv6
|
|
|
|
|
|
|
|
|
|
def validate(self) -> List[str]:
|
|
|
|
|
result = []
|
|
|
|
|
result += self.__validate_is_not_empty__("fqdn")
|
|
|
|
|
if (not self.ipv4) and (not self.ipv6):
|
|
|
|
|
result.append("ipv4 & ipv6 may not both be empty.")
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Build(Validateable):
|
|
|
|
|
def __init__(self, config):
|
|
|
|
|
self.stage = config["stage"]
|
|
|
|
@ -37,12 +51,6 @@ class Build(Validateable):
|
|
|
|
|
path = [self.project_root_path, self.build_dir_name, self.name, self.module]
|
|
|
|
|
return "/".join(filter_none(path))
|
|
|
|
|
|
|
|
|
|
# TODO: these functions should be located at TerraformBuild later on.
|
|
|
|
|
def update_runtime_config(self, fqdn, ipv4, ipv6):
|
|
|
|
|
self.__put__("fqdn", fqdn)
|
|
|
|
|
self.__put__("ipv4", ipv4)
|
|
|
|
|
self.__put__("ipv6", ipv6)
|
|
|
|
|
|
|
|
|
|
def __put__(self, key, value):
|
|
|
|
|
self.stack[key] = value
|
|
|
|
|
|
|
|
|
@ -57,7 +65,7 @@ class Build(Validateable):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DockerBuild(Validateable):
|
|
|
|
|
def __init__(self, config):
|
|
|
|
|
def __init__(self, config: map):
|
|
|
|
|
self.dockerhub_user = config["dockerhub_user"]
|
|
|
|
|
self.dockerhub_password = config["dockerhub_password"]
|
|
|
|
|
self.use_package_common_files = config["use_package_common_files"]
|
|
|
|
@ -71,31 +79,37 @@ class DockerBuild(Validateable):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class C4kBuild(Validateable):
|
|
|
|
|
def __init__(self, build: Build, project, config):
|
|
|
|
|
self.build = build
|
|
|
|
|
def __init__(self, config: map):
|
|
|
|
|
tmp_executabel_name = config["C4kMixin"]["executabel_name"]
|
|
|
|
|
if not tmp_executabel_name:
|
|
|
|
|
tmp_executabel_name = self.build.module
|
|
|
|
|
tmp_executabel_name = config["module"]
|
|
|
|
|
self.executabel_name = tmp_executabel_name
|
|
|
|
|
self.c4k_mixin_config = config["C4kMixin"]["config"]
|
|
|
|
|
self.c4k_mixin_auth = config["C4kMixin"]["auth"]
|
|
|
|
|
tmp = self.c4k_mixin_config["mon-cfg"]
|
|
|
|
|
tmp.update(
|
|
|
|
|
{"cluster-name": self.build.module, "cluster-stage": self.build.stage}
|
|
|
|
|
)
|
|
|
|
|
tmp.update({"cluster-name": config["module"], "cluster-stage": config["stage"]})
|
|
|
|
|
self.c4k_mixin_config.update({"mon-cfg": tmp})
|
|
|
|
|
self.dns_record = None
|
|
|
|
|
|
|
|
|
|
# TODO: these functions should be located at TerraformBuild later on.
|
|
|
|
|
def update_runtime_config(self, dns_record: DnsRecord):
|
|
|
|
|
self.dns_record = dns_record
|
|
|
|
|
|
|
|
|
|
def update_runtime_config(self, fqdn, ipv4, ipv6):
|
|
|
|
|
self.build.update_runtime_config(fqdn, ipv4, ipv6)
|
|
|
|
|
def validate(self) -> List[str]:
|
|
|
|
|
result = []
|
|
|
|
|
result += self.__validate_is_not_empty__("fqdn")
|
|
|
|
|
if self.dns_record:
|
|
|
|
|
result += self.dns_record.validate()
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def config(self):
|
|
|
|
|
fqdn = self.build.__get__("fqdn")
|
|
|
|
|
fqdn = self.dns_record.fqdn
|
|
|
|
|
self.c4k_mixin_config.update({"fqdn": fqdn})
|
|
|
|
|
return self.c4k_mixin_config
|
|
|
|
|
|
|
|
|
|
def command(self):
|
|
|
|
|
module = self.build.module
|
|
|
|
|
build_path = self.build.build_path()
|
|
|
|
|
def command(self, build: Build):
|
|
|
|
|
module = build.module
|
|
|
|
|
build_path = build.build_path()
|
|
|
|
|
config_path = f"{build_path}/out_c4k_config.yaml"
|
|
|
|
|
auth_path = f"{build_path}/out_c4k_auth.yaml"
|
|
|
|
|
output_path = f"{build_path}/out_{module}.yaml"
|
|
|
|
|