From 4539b84d6c1cf80991d97996d8623de95aba23e4 Mon Sep 17 00:00:00 2001 From: patdyn Date: Wed, 26 Jun 2024 10:35:53 +0200 Subject: [PATCH] WIP implement tf backend git provider --- .../ddadevops/domain/provider_tfGitBackend.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/main/python/ddadevops/domain/provider_tfGitBackend.py diff --git a/src/main/python/ddadevops/domain/provider_tfGitBackend.py b/src/main/python/ddadevops/domain/provider_tfGitBackend.py new file mode 100644 index 0000000..e1dd377 --- /dev/null +++ b/src/main/python/ddadevops/domain/provider_tfGitBackend.py @@ -0,0 +1,44 @@ +from typing import List, Dict, Set, Any +from .common import Validateable, CredentialMappingDefault + +class TerraformGitBackend(Validateable, CredentialMappingDefault): + def __init__( + self, + inp: dict, + ): + self.stage = inp.get("stage") + self.module = inp.get("module") + self.git_backend_repo = inp.get("git_backend_repo") + self.git_backend_ref = inp.get("git_backend_ref") + self.git_backend_state = inp.get("git_backend_state") + self.git_backend_username = inp.get("git_backend_username") + self.git_backend_token = inp.get("git_backend_token") + + def validate(self) -> List[str]: + result = [] + result += self.__validate_is_not_empty__("stage") + result += self.__validate_is_not_empty__("module") + result += self.__validate_is_not_empty__("git_backend_repo") + result += self.__validate_is_not_empty__("git_backend_ref") + result += self.__validate_is_not_empty__("git_backend_state") + result += self.__validate_is_not_empty__("git_backend_username") + result += self.__validate_is_not_empty__("git_backend_token") + + 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, + } + + def project_vars(self): + return { + "git_backend_token": self.git_backend_token, + "git_backend_username": self.git_backend_username, + } + +