From f9f2389c95cbf9c70bce28f943a5514f45b7d5e0 Mon Sep 17 00:00:00 2001 From: patdyn Date: Wed, 26 Jun 2024 16:52:40 +0200 Subject: [PATCH] Update provider with correct vars --- .../domain/provider_tf_backend_git.py | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) 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 cf75d5d..c6f4190 100644 --- a/src/main/python/ddadevops/domain/provider_tf_backend_git.py +++ b/src/main/python/ddadevops/domain/provider_tf_backend_git.py @@ -25,22 +25,38 @@ class TerraformBackendGit(Validateable, CredentialMappingDefault): result += self.__validate_is_not_empty__("git_backend_token") return result - + + # See: https://developer.hashicorp.com/terraform/language/settings/backends/configuration#command-line-key-value-pairs + # and https://github.com/plumber-cd/terraform-backend-git?tab=readme-ov-file#standalone-terraform-http-backend-mode 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, + "address": self.__make_http_backend_address__(self.git_backend_repo, self.git_backend_ref, self.git_backend_state), + "lock_address": self.__make_http_backend_address__(self.git_backend_repo, self.git_backend_ref, self.git_backend_state), + "unlock_address": self.__make_http_backend_address__(self.git_backend_repo, self.git_backend_ref, self.git_backend_state), } - def project_vars(self): + def resources_from_package(self) -> List[str]: + return {"tf_backend_git_backend.tf", "tf_backend_git_backend_vars.tf"} + + # ToDo: This can not be used for backend config, as the backend block can not reference vars. + def project_vars(self) -> Dict[str, Any]: return { - "git_backend_token": self.git_backend_token, - "git_backend_username": self.git_backend_username, + "http_backend_address": self.__make_http_backend_address__(self.git_backend_ref, self.git_backend_repo, self.git_backend_state) } - #ToDo: + + def is_local_state(self): + return False + + # ToDo: + def __bucket_key__(self): + pass + + # ToDo: + def __make_http_backend_address__(self): + pass + + # ToDo: + @classmethod def get_mapping_default(): pass