Rename to TERRAFORM_BACKEND_GIT

This commit is contained in:
patdyn 2024-06-26 15:25:34 +02:00
parent 6e5275b56b
commit 4eadad3940
4 changed files with 23 additions and 13 deletions

View file

@ -17,6 +17,7 @@ class ProviderType(Enum):
DIGITALOCEAN = 0 DIGITALOCEAN = 0
HETZNER = 1 HETZNER = 1
AWS = 2 AWS = 2
TERRAFORM_BACKEND_GIT = 3
class MixinType(Enum): class MixinType(Enum):

View file

@ -6,6 +6,7 @@ from .devops_factory import DevopsFactory
from .terraform import TerraformDomain from .terraform import TerraformDomain
from .provider_digitalocean import Digitalocean from .provider_digitalocean import Digitalocean
from .provider_hetzner import Hetzner from .provider_hetzner import Hetzner
from .provider_tf_backend_git import TerraformBackendGit
from .c4k import C4k from .c4k import C4k
from .image import Image from .image import Image
from .release import ReleaseType, Release from .release import ReleaseType, Release
@ -60,6 +61,8 @@ class InitService:
default_mappings += Digitalocean.get_mapping_default() default_mappings += Digitalocean.get_mapping_default()
if ProviderType.HETZNER in provider_types: if ProviderType.HETZNER in provider_types:
default_mappings += Hetzner.get_mapping_default() default_mappings += Hetzner.get_mapping_default()
if ProviderType.TERRAFORM_BACKEND_GIT in provider_types:
default_mappings += TerraformBackendGit.get_mapping_default()
if MixinType.RELEASE in mixin_types: if MixinType.RELEASE in mixin_types:
primary_build_file_id = inp.get( primary_build_file_id = inp.get(

View file

@ -1,7 +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
class TerraformGitBackend(Validateable, CredentialMappingDefault): class TerraformBackendGit(Validateable, CredentialMappingDefault):
def __init__( def __init__(
self, self,
inp: dict, inp: dict,
@ -27,18 +27,21 @@ class TerraformGitBackend(Validateable, CredentialMappingDefault):
return result return result
def backend_config(self) -> Dict[str, Any]: def backend_config(self) -> Dict[str, Any]:
return { return {
"git_backend_repo": self.git_backend_repo, "git_backend_repo": self.git_backend_repo,
"git_backend_ref": self.git_backend_ref, "git_backend_ref": self.git_backend_ref,
"git_backend_state": self.git_backend_state, "git_backend_state": self.git_backend_state,
"git_backend_username": self.git_backend_username, "git_backend_username": self.git_backend_username,
"git_backend_token": self.git_backend_token, "git_backend_token": self.git_backend_token,
} }
def project_vars(self): def project_vars(self):
return { return {
"git_backend_token": self.git_backend_token, "git_backend_token": self.git_backend_token,
"git_backend_username": self.git_backend_username, "git_backend_username": self.git_backend_username,
} }
#ToDo:
def get_mapping_default():
pass

View file

@ -8,6 +8,7 @@ from .common import (
from .provider_digitalocean import Digitalocean from .provider_digitalocean import Digitalocean
from .provider_hetzner import Hetzner from .provider_hetzner import Hetzner
from .provider_aws import Aws from .provider_aws import Aws
from .provider_tf_backend_git import TerraformBackendGit
class TerraformDomain(Validateable): class TerraformDomain(Validateable):
@ -42,6 +43,8 @@ class TerraformDomain(Validateable):
self.providers[ProviderType.HETZNER] = Hetzner(inp) self.providers[ProviderType.HETZNER] = Hetzner(inp)
if ProviderType.AWS in provider_types: if ProviderType.AWS in provider_types:
self.providers[ProviderType.AWS] = Aws(inp) self.providers[ProviderType.AWS] = Aws(inp)
if ProviderType.TERRAFORM_BACKEND_GIT in provider_types:
self.providers[ProviderType.TERRAFORM_BACKEND_GIT] = TerraformBackendGit(inp)
def validate(self) -> List[str]: def validate(self) -> List[str]:
result = [] result = []
@ -87,7 +90,7 @@ class TerraformDomain(Validateable):
return result return result
def uses_backend_git(self) -> bool: def uses_backend_git(self) -> bool:
return ProviderType.TERRAFORM_GIT_BACKEND in self.providers.keys() return ProviderType.TERRAFORM_BACKEND_GIT in self.providers.keys()
def backend_config(self) -> Dict[str, Any]: def backend_config(self) -> Dict[str, Any]:
result = {} result = {}