From 496e71d26c1aee487b3b22f67f555dd9571d1327 Mon Sep 17 00:00:00 2001 From: EarthmanT Date: Wed, 19 Oct 2022 11:33:16 -0400 Subject: [PATCH] =?UTF-8?q?Rd=205968=20clone=20tf=20error=20messages=20are?= =?UTF-8?q?=20unhelpful=20if=20terraform=20binary=20doe=E2=80=A6=20(#223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rd 5968 clone tf error messages are unhelpful if terraform binary does not exist (#222) * added error messages for when Terraform binary does not exist * bump version * bump version * bump version * updated error text * fixed typo * fixed indentation * try different logic Co-authored-by: EarthmanT * make change Co-authored-by: kaplanyaniv <87370053+kaplanyaniv@users.noreply.github.com> --- CHANGELOG.txt | 2 ++ cloudify_tf/utils.py | 25 ++++++++++++++++--------- plugin.yaml | 2 +- plugin_1_4.yaml | 2 +- v2_plugin.yaml | 2 +- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e813e2b..f4a4e9b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,5 @@ +0.19.10: + - TF error messages are unhelpful if Terraform binary does not exist 0.19.9: - Fix the tfvars flag for older tfsec versions 0.19.8: diff --git a/cloudify_tf/utils.py b/cloudify_tf/utils.py index 68d42e0..c262b29 100644 --- a/cloudify_tf/utils.py +++ b/cloudify_tf/utils.py @@ -258,19 +258,26 @@ def is_using_existing(target=True): def get_binary_location_from_rel(): - tf_rel = find_terraform_node_from_rel() - terraform_config = tf_rel.target.node.properties.get( - 'terraform_config', {}) - candidate_a = terraform_config.get('executable_path') candidate_b = get_executable_path() if candidate_b and os.path.isfile(candidate_b): + ctx.logger.debug( + 'Executable path from node {}'.format(candidate_b)) return candidate_b - if candidate_a and os.path.isfile(candidate_a): - return candidate_a + tf_rel = find_terraform_node_from_rel() + if tf_rel: + terraform_config = tf_rel.target.node.properties.get( + 'terraform_config', {}) + candidate_a = terraform_config.get('executable_path') + if candidate_a and os.path.isfile(candidate_a): + ctx.logger.debug( + 'Executable path from rel {}'.format(candidate_a)) + return candidate_a raise NonRecoverableError( - "Terraform's executable not found in {0} or {1}. Please set the " - "'executable_path' property accordingly.".format( - candidate_b, candidate_a)) + "Terraform's executable not found from relationship " + "'cloudify.terraform.relationships.run_on_host' to type " + "'cloudify.nodes.terraform' or by setting the value in " + "'terraform_config'. Please set the 'executable_path' property " + "accordingly.") def find_terraform_node_from_rel(): diff --git a/plugin.yaml b/plugin.yaml index eeebf7b..a76cf5a 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -2,7 +2,7 @@ plugins: tf: executor: central_deployment_agent package_name: cloudify-terraform-plugin - package_version: '0.19.9' + package_version: '0.19.10' dsl_definitions: diff --git a/plugin_1_4.yaml b/plugin_1_4.yaml index f5c5af8..a8f2835 100644 --- a/plugin_1_4.yaml +++ b/plugin_1_4.yaml @@ -2,7 +2,7 @@ plugins: tf: executor: central_deployment_agent package_name: cloudify-terraform-plugin - package_version: '0.19.9' + package_version: '0.19.10' dsl_definitions: diff --git a/v2_plugin.yaml b/v2_plugin.yaml index d525013..85bff71 100644 --- a/v2_plugin.yaml +++ b/v2_plugin.yaml @@ -2,7 +2,7 @@ plugins: tf: executor: central_deployment_agent package_name: cloudify-terraform-plugin - package_version: '0.19.9' + package_version: '0.19.10' dsl_definitions: