Skip to content

Commit

Permalink
Rd 5968 clone tf error messages are unhelpful if terraform binary doe…
Browse files Browse the repository at this point in the history
…… (#223)

* 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 <[email protected]>

* make change

Co-authored-by: kaplanyaniv <[email protected]>
  • Loading branch information
EarthmanT and kaplanyaniv authored Oct 19, 2022
1 parent 0e81564 commit 496e71d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
25 changes: 16 additions & 9 deletions cloudify_tf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion plugin_1_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion v2_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 496e71d

Please sign in to comment.