|
|
@ -7,19 +7,38 @@ class Digitalocean(Validateable, CredentialMappingDefault):
|
|
|
|
self,
|
|
|
|
self,
|
|
|
|
inp: dict,
|
|
|
|
inp: dict,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
|
|
|
|
self.stage = inp.get("stage")
|
|
|
|
|
|
|
|
self.module = inp.get("module")
|
|
|
|
self.do_api_key = inp.get("do_api_key")
|
|
|
|
self.do_api_key = inp.get("do_api_key")
|
|
|
|
self.do_spaces_access_id = inp.get("do_spaces_access_id")
|
|
|
|
self.do_spaces_access_id = inp.get("do_spaces_access_id")
|
|
|
|
self.do_spaces_secret_key = inp.get("do_spaces_secret_key")
|
|
|
|
self.do_spaces_secret_key = inp.get("do_spaces_secret_key")
|
|
|
|
|
|
|
|
self.do_as_backend = inp.get("do_as_backend", False)
|
|
|
|
|
|
|
|
self.do_account_name = inp.get("do_account_name")
|
|
|
|
|
|
|
|
self.do_endpoint = inp.get("do_endpoint")
|
|
|
|
|
|
|
|
self.do_bucket = inp.get("do_bucket")
|
|
|
|
|
|
|
|
self.do_bucket_key = inp.get("do_bucket_key")
|
|
|
|
|
|
|
|
self.do_region = inp.get("do_region")
|
|
|
|
|
|
|
|
|
|
|
|
def validate(self) -> List[str]:
|
|
|
|
def validate(self) -> List[str]:
|
|
|
|
result = []
|
|
|
|
result = []
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("stage")
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("module")
|
|
|
|
result += self.__validate_is_not_empty__("do_api_key")
|
|
|
|
result += self.__validate_is_not_empty__("do_api_key")
|
|
|
|
result += self.__validate_is_not_empty__("do_spaces_access_id")
|
|
|
|
result += self.__validate_is_not_empty__("do_spaces_access_id")
|
|
|
|
result += self.__validate_is_not_empty__("do_spaces_secret_key")
|
|
|
|
result += self.__validate_is_not_empty__("do_spaces_secret_key")
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("do_spaces_secret_key")
|
|
|
|
|
|
|
|
result += self.__validate_is_not_none__("do_as_backend")
|
|
|
|
|
|
|
|
if self.do_as_backend:
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("do_endpoint")
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("do_bucket")
|
|
|
|
|
|
|
|
result += self.__validate_is_not_empty__("do_region")
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def resources_from_package(self) -> Set[str]:
|
|
|
|
def resources_from_package(self) -> Set[str]:
|
|
|
|
return {"provider_registry.tf", "do_provider.tf", "do_mixin_vars.tf"}
|
|
|
|
result = {"provider_registry.tf", "do_provider.tf", "do_mixin_vars.tf"}
|
|
|
|
|
|
|
|
if self.do_as_backend:
|
|
|
|
|
|
|
|
result.update({"do_backend_properties_vars.tf", "do_backend_with_properties.tf"})
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def project_vars(self):
|
|
|
|
def project_vars(self):
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -28,6 +47,23 @@ class Digitalocean(Validateable, CredentialMappingDefault):
|
|
|
|
"do_spaces_secret_key": self.do_spaces_secret_key,
|
|
|
|
"do_spaces_secret_key": self.do_spaces_secret_key,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def backend_config(self) -> map:
|
|
|
|
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
if self.do_as_backend:
|
|
|
|
|
|
|
|
if self.do_account_name and self.do_bucket_key:
|
|
|
|
|
|
|
|
bucket_key = f"{self.do_account_name}/{self.do_bucket_key}"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
bucket_key = f"{self.stage}/{self.module}"
|
|
|
|
|
|
|
|
result = {
|
|
|
|
|
|
|
|
"access_key": self.do_spaces_access_id,
|
|
|
|
|
|
|
|
"secret_key": self.do_spaces_secret_key,
|
|
|
|
|
|
|
|
"endpoint": self.do_endpoint,
|
|
|
|
|
|
|
|
"bucket": self.do_bucket,
|
|
|
|
|
|
|
|
"key": bucket_key,
|
|
|
|
|
|
|
|
"region": self.do_region,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
|
|
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|