Compare commits
3 commits
a0dbb79d30
...
24579506ae
Author | SHA1 | Date | |
---|---|---|---|
24579506ae | |||
07169c5b3d | |||
872b29179e |
3 changed files with 18 additions and 7 deletions
|
@ -1,8 +1,7 @@
|
||||||
from typing import List, Dict, Set, Any
|
from typing import List, Dict, Set, Any
|
||||||
from .common import Validateable, CredentialMappingDefault
|
from .common import Validateable, CredentialMappingDefault
|
||||||
|
|
||||||
# TODO: Add a 'git_as_backend' option
|
|
||||||
# TODO: Check this option at the right places
|
|
||||||
class TerraformBackendGit(Validateable, CredentialMappingDefault):
|
class TerraformBackendGit(Validateable, CredentialMappingDefault):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -40,10 +39,11 @@ class TerraformBackendGit(Validateable, CredentialMappingDefault):
|
||||||
def resources_from_package(self) -> Set[str]:
|
def resources_from_package(self) -> Set[str]:
|
||||||
return {"tf_backend_git_backend.tf", "tf_backend_git_backend_vars.tf"}
|
return {"tf_backend_git_backend.tf", "tf_backend_git_backend_vars.tf"}
|
||||||
|
|
||||||
# TODO: This can not be used for backend config, as the backend block can not reference vars.
|
# TODO: This can not be used for backend, as the backend block can not reference vars.
|
||||||
|
# This is another reason to introduce a 'backend' object
|
||||||
def project_vars(self) -> Dict[str, Any]:
|
def project_vars(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
"http_backend_address": self.__make_http_backend_address__()
|
"": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_local_state(self):
|
def is_local_state(self):
|
||||||
|
|
|
@ -90,12 +90,11 @@ class TerraformDomain(Validateable):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def uses_backend_git(self) -> bool:
|
def uses_backend_git(self) -> bool:
|
||||||
if ProviderType.TERRAFORM_BACKEND_GIT in self.providers.keys():
|
if ProviderType.TERRAFORM_BACKEND_GIT in self.providers:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# TODO: Add ssh method case and make this default
|
# TODO: Add ssh method case and make this default
|
||||||
# TODO: How do we get to the credentials?
|
|
||||||
def env_credentials(self) -> Dict[str, str]:
|
def env_credentials(self) -> Dict[str, str]:
|
||||||
tf_backend_git = self.providers[ProviderType.TERRAFORM_BACKEND_GIT]
|
tf_backend_git = self.providers[ProviderType.TERRAFORM_BACKEND_GIT]
|
||||||
if tf_backend_git.git_backend_token != "":
|
if tf_backend_git.git_backend_token != "":
|
||||||
|
|
|
@ -78,6 +78,7 @@ def test_should_calculate_project_vars():
|
||||||
{
|
{
|
||||||
"do_as_backend": False,
|
"do_as_backend": False,
|
||||||
"aws_as_backend": False,
|
"aws_as_backend": False,
|
||||||
|
"tf_provider_types": ["DIGITALOCEAN", "HETZNER", "AWS"]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
sut = TerraformDomain(config)
|
sut = TerraformDomain(config)
|
||||||
|
@ -167,6 +168,17 @@ def test_should_calculate_resources_from_package():
|
||||||
"aws_provider_vars.tf",
|
"aws_provider_vars.tf",
|
||||||
"aws_backend_wkms_vars.tf",
|
"aws_backend_wkms_vars.tf",
|
||||||
"my.file",
|
"my.file",
|
||||||
|
"tf_backend_git_backend_vars.tf",
|
||||||
|
"tf_backend_git_backend.tf",
|
||||||
|
} == sut.resources_from_package()
|
||||||
|
|
||||||
|
config = devops_config({"tf_provider_types": ["TERRAFORM_BACKEND_GIT"]})
|
||||||
|
sut = TerraformDomain(config)
|
||||||
|
assert {
|
||||||
|
"versions.tf",
|
||||||
|
"terraform_build_vars.tf",
|
||||||
|
"tf_backend_git_backend_vars.tf",
|
||||||
|
"tf_backend_git_backend.tf",
|
||||||
} == sut.resources_from_package()
|
} == sut.resources_from_package()
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,4 +204,4 @@ def test_should_calculate_local_state_handling():
|
||||||
|
|
||||||
def test_should_use_backend_git():
|
def test_should_use_backend_git():
|
||||||
sut = TerraformDomain(devops_config({}))
|
sut = TerraformDomain(devops_config({}))
|
||||||
assert TerraformDomain.uses_backend_git()
|
assert sut.uses_backend_git()
|
Loading…
Reference in a new issue