add project vars fkt

merge-requests/14/merge
Michael Jerger 1 year ago
parent e4fef8b61c
commit d909251c08

@ -31,6 +31,7 @@ class Terraform(Validateable):
def validate(self) -> List[str]:
result = []
result += self.__validate_is_not_empty__("module")
result += self.__validate_is_not_empty__("stage")
result += self.__validate_is_not_empty__("tf_build_commons_dir_name")
return result
@ -43,3 +44,9 @@ class Terraform(Validateable):
def terraform_build_commons_path(self) -> Path:
mylist = [self.tf_build_commons_path, self.tf_build_commons_dir_name]
return Path("/".join(filter_none(mylist)) + "/")
def project_vars(self):
ret = {"stage": self.stage, "module": self.module}
if self.tf_additional_vars:
ret.update(self.tf_additional_vars)
return ret

@ -31,3 +31,8 @@ def test_should_calculate_terraform_build_commons_path():
config = devops_config({})
sut = Terraform(config)
assert Path("build_commons_path/terraform") == sut.terraform_build_commons_path()
def test_should_calculate_project_vars():
config = devops_config({})
sut = Terraform(config)
assert {'module': 'module', 'stage': 'test'} == sut.project_vars()

Loading…
Cancel
Save