add project vars fkt
This commit is contained in:
parent
e4fef8b61c
commit
d909251c08
2 changed files with 12 additions and 0 deletions
|
@ -31,6 +31,7 @@ class Terraform(Validateable):
|
||||||
def validate(self) -> List[str]:
|
def validate(self) -> List[str]:
|
||||||
result = []
|
result = []
|
||||||
result += self.__validate_is_not_empty__("module")
|
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")
|
result += self.__validate_is_not_empty__("tf_build_commons_dir_name")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -43,3 +44,9 @@ class Terraform(Validateable):
|
||||||
def terraform_build_commons_path(self) -> Path:
|
def terraform_build_commons_path(self) -> Path:
|
||||||
mylist = [self.tf_build_commons_path, self.tf_build_commons_dir_name]
|
mylist = [self.tf_build_commons_path, self.tf_build_commons_dir_name]
|
||||||
return Path("/".join(filter_none(mylist)) + "/")
|
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({})
|
config = devops_config({})
|
||||||
sut = Terraform(config)
|
sut = Terraform(config)
|
||||||
assert Path("build_commons_path/terraform") == sut.terraform_build_commons_path()
|
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…
Reference in a new issue