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, + } + +