From 68fbb5cb6dc881be4077366208f06ae63381c4aa Mon Sep 17 00:00:00 2001 From: Ara Ghukasyan Date: Mon, 29 Jan 2024 22:35:16 -0500 Subject: [PATCH] make staticmethod --- covalent/cloud_resource_manager/core.py | 50 +++++++++++++------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/covalent/cloud_resource_manager/core.py b/covalent/cloud_resource_manager/core.py index 98bed6f7f..eb63bb604 100644 --- a/covalent/cloud_resource_manager/core.py +++ b/covalent/cloud_resource_manager/core.py @@ -391,30 +391,6 @@ def _get_tf_statefile_path(self) -> str: # Saving in a directory which doesn't get deleted on purge return str(Path(self.executor_tf_path) / "terraform.tfstate") - def _convert_to_tfvar(self, value: Any) -> Any: - """ - Convert the value to a string that can be parsed as a terraform variable. - - Args: - value: Value to convert - - Returns: - Converted value - - """ - if value is True: - return "true" - if value is False: - return "false" - if value is None: - return "null" - if isinstance(value, str): - return f'"{value}"' - if isinstance(value, Sequence): - return str(list(value)) - - return str(value) - def up(self, print_callback: Callable, dry_run: bool = True) -> None: """ Spin up executor resources with terraform @@ -561,3 +537,29 @@ def status(self) -> None: # Run `terraform state list` return self._run_in_subprocess(cmd=tf_state, env_vars=self._terraform_log_env_vars) + + @staticmethod + def _convert_to_tfvar(value: Any) -> Any: + """ + Convert the value to a string that can be parsed as a terraform variable. + + Args: + value: Value to convert + + Returns: + Converted value + + """ + if value is True: + return "true" + if value is False: + return "false" + if value is None: + return "null" + if isinstance(value, str): + return f'"{value}"' + if isinstance(value, Sequence): + values = [CloudResourceManager._convert_to_tfvar(v) for v in value] + return f"[{', '.join(values)}]" + + return str(value)