c4kBuild is working
This commit is contained in:
parent
2a4a2d25d8
commit
331b3bba6e
2 changed files with 24 additions and 34 deletions
|
@ -53,23 +53,26 @@ class C4kBuild(DevopsBuild):
|
|||
raise ValueError(f"C4kBuild requires BuildType.C4K")
|
||||
|
||||
def update_runtime_config(self, dns_record: DnsRecord):
|
||||
c4k_build = self.repo.get_c4k(self.project)
|
||||
c4k_build.update_runtime_config(dns_record)
|
||||
self.repo.set_c4k(self.project, c4k_build)
|
||||
devops = self.repo.get_devops(self.project)
|
||||
devops.specialized_builds[BuildType.C4K].update_runtime_config(dns_record)
|
||||
self.repo.set_devops(self.project, devops)
|
||||
|
||||
def write_c4k_config(self):
|
||||
build = self.repo.get_devops(self.project)
|
||||
c4k_build = self.repo.get_c4k(self.project)
|
||||
path = build.build_path() + "/out_c4k_config.yaml"
|
||||
self.file_api.write_yaml_to_file(path, c4k_build.config())
|
||||
devops = self.repo.get_devops(self.project)
|
||||
path = devops.build_path() + "/out_c4k_config.yaml"
|
||||
self.file_api.write_yaml_to_file(
|
||||
path, devops.specialized_builds[BuildType.C4K].config()
|
||||
)
|
||||
|
||||
def write_c4k_auth(self):
|
||||
build = self.repo.get_devops(self.project)
|
||||
c4k_build = self.repo.get_c4k(self.project)
|
||||
path = build.build_path() + "/out_c4k_auth.yaml"
|
||||
self.file_api.write_yaml_to_file(path, c4k_build.c4k_mixin_auth)
|
||||
devops = self.repo.get_devops(self.project)
|
||||
path = devops.build_path() + "/out_c4k_auth.yaml"
|
||||
self.file_api.write_yaml_to_file(
|
||||
path, devops.specialized_builds[BuildType.C4K].auth()
|
||||
)
|
||||
|
||||
def c4k_apply(self, dry_run=False):
|
||||
build = self.repo.get_devops(self.project)
|
||||
c4k_build = self.repo.get_c4k(self.project)
|
||||
return self.execution_api.execute(c4k_build.command(build), dry_run)
|
||||
devops = self.repo.get_devops(self.project)
|
||||
return self.execution_api.execute(
|
||||
devops.specialized_builds[BuildType.C4K].command(devops), dry_run
|
||||
)
|
||||
|
|
|
@ -5,10 +5,6 @@ from src.main.python.ddadevops.c4k_build import C4kBuild, add_c4k_mixin_config
|
|||
from .domain.test_helper import devops_config
|
||||
|
||||
|
||||
class MyC4kBuild(C4kBuild):
|
||||
pass
|
||||
|
||||
|
||||
def test_c4k_mixin(tmp_path):
|
||||
build_dir = "build"
|
||||
project_name = "testing-project"
|
||||
|
@ -16,7 +12,7 @@ def test_c4k_mixin(tmp_path):
|
|||
tmp_path_str = str(tmp_path)
|
||||
|
||||
project = Project(tmp_path_str, name=project_name)
|
||||
sut = MyC4kBuild(
|
||||
sut = C4kBuild(
|
||||
project,
|
||||
devops_config(
|
||||
{
|
||||
|
@ -25,27 +21,18 @@ def test_c4k_mixin(tmp_path):
|
|||
"module": "c4k-test",
|
||||
"c4k_config": {"a": 1, "b": 2},
|
||||
"c4k_auth": {"c": 3, "d": 4},
|
||||
"grafana_cloud_user": "user",
|
||||
"grafana_cloud_password": "password",
|
||||
'grafana_cloud_url': "https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push",
|
||||
"c4k_grafana_cloud_user": "user",
|
||||
"c4k_grafana_cloud_password": "password",
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
sut.initialize_build_dir()
|
||||
assert (
|
||||
sut.build_path() == f"{tmp_path_str}/target/mybuild/c4k-test"
|
||||
)
|
||||
|
||||
# TODO: mv this to domain test
|
||||
# sut.update_runtime_config(DnsRecord("test.de", ipv6="1::"))
|
||||
# assert "fqdn" in sut.specialized_builds[BuildType.C4K].config()
|
||||
# assert "mon-cfg" in sut.specialized_builds[BuildType.C4K].config()
|
||||
# assert "mon-auth" in sut.specialized_builds[BuildType.C4K].c4k_mixin_auth
|
||||
assert sut.build_path() == f"{tmp_path_str}/target/name/c4k-test"
|
||||
|
||||
sut.update_runtime_config(DnsRecord("test.de", ipv6="::1"))
|
||||
sut.write_c4k_config()
|
||||
assert os.path.exists(f"{mixin.build_path()}/out_c4k_config.yaml")
|
||||
assert os.path.exists(f"{sut.build_path()}/out_c4k_config.yaml")
|
||||
|
||||
sut.write_c4k_auth()
|
||||
assert os.path.exists(f"{mixin.build_path()}/out_c4k_auth.yaml")
|
||||
assert os.path.exists(f"{sut.build_path()}/out_c4k_auth.yaml")
|
||||
|
|
Loading…
Reference in a new issue