From 4eadad39403c8fb47265dde45c711e828b88d05c Mon Sep 17 00:00:00 2001 From: patdyn Date: Wed, 26 Jun 2024 15:25:34 +0200 Subject: [PATCH] Rename to TERRAFORM_BACKEND_GIT --- src/main/python/ddadevops/domain/common.py | 1 + .../python/ddadevops/domain/init_service.py | 3 +++ .../domain/provider_tf_backend_git.py | 27 ++++++++++--------- src/main/python/ddadevops/domain/terraform.py | 5 +++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/python/ddadevops/domain/common.py b/src/main/python/ddadevops/domain/common.py index fc32311..9c13ba2 100644 --- a/src/main/python/ddadevops/domain/common.py +++ b/src/main/python/ddadevops/domain/common.py @@ -17,6 +17,7 @@ class ProviderType(Enum): DIGITALOCEAN = 0 HETZNER = 1 AWS = 2 + TERRAFORM_BACKEND_GIT = 3 class MixinType(Enum): diff --git a/src/main/python/ddadevops/domain/init_service.py b/src/main/python/ddadevops/domain/init_service.py index 8529665..c0417b9 100644 --- a/src/main/python/ddadevops/domain/init_service.py +++ b/src/main/python/ddadevops/domain/init_service.py @@ -6,6 +6,7 @@ from .devops_factory import DevopsFactory from .terraform import TerraformDomain from .provider_digitalocean import Digitalocean from .provider_hetzner import Hetzner +from .provider_tf_backend_git import TerraformBackendGit from .c4k import C4k from .image import Image from .release import ReleaseType, Release @@ -60,6 +61,8 @@ class InitService: default_mappings += Digitalocean.get_mapping_default() if ProviderType.HETZNER in provider_types: 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: primary_build_file_id = inp.get( diff --git a/src/main/python/ddadevops/domain/provider_tf_backend_git.py b/src/main/python/ddadevops/domain/provider_tf_backend_git.py index e1dd377..cf75d5d 100644 --- a/src/main/python/ddadevops/domain/provider_tf_backend_git.py +++ b/src/main/python/ddadevops/domain/provider_tf_backend_git.py @@ -1,7 +1,7 @@ from typing import List, Dict, Set, Any from .common import Validateable, CredentialMappingDefault -class TerraformGitBackend(Validateable, CredentialMappingDefault): +class TerraformBackendGit(Validateable, CredentialMappingDefault): def __init__( self, inp: dict, @@ -27,18 +27,21 @@ class TerraformGitBackend(Validateable, CredentialMappingDefault): return result def backend_config(self) -> Dict[str, Any]: - return { - "git_backend_repo": self.git_backend_repo, - "git_backend_ref": self.git_backend_ref, - "git_backend_state": self.git_backend_state, - "git_backend_username": self.git_backend_username, - "git_backend_token": self.git_backend_token, - } + return { + "git_backend_repo": self.git_backend_repo, + "git_backend_ref": self.git_backend_ref, + "git_backend_state": self.git_backend_state, + "git_backend_username": self.git_backend_username, + "git_backend_token": self.git_backend_token, + } def project_vars(self): - return { - "git_backend_token": self.git_backend_token, - "git_backend_username": self.git_backend_username, - } + return { + "git_backend_token": self.git_backend_token, + "git_backend_username": self.git_backend_username, + } + #ToDo: + def get_mapping_default(): + pass diff --git a/src/main/python/ddadevops/domain/terraform.py b/src/main/python/ddadevops/domain/terraform.py index f45e091..c70c7f5 100644 --- a/src/main/python/ddadevops/domain/terraform.py +++ b/src/main/python/ddadevops/domain/terraform.py @@ -8,6 +8,7 @@ from .common import ( from .provider_digitalocean import Digitalocean from .provider_hetzner import Hetzner from .provider_aws import Aws +from .provider_tf_backend_git import TerraformBackendGit class TerraformDomain(Validateable): @@ -42,6 +43,8 @@ class TerraformDomain(Validateable): self.providers[ProviderType.HETZNER] = Hetzner(inp) if ProviderType.AWS in provider_types: 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]: result = [] @@ -87,7 +90,7 @@ class TerraformDomain(Validateable): return result 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]: result = {}