WIP implement tf backend git provider

This commit is contained in:
patdyn 2024-06-26 10:35:53 +02:00
parent f4da27f63f
commit 4539b84d6c

View file

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