Skip to content

Commit

Permalink
Handled the use case where current terraform version is older than th…
Browse files Browse the repository at this point in the history
…e plan file.
  • Loading branch information
eerkunt committed Jun 4, 2021
1 parent ae336ca commit 04978f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Added an auto-detection mechanism for terraform version while converting the plan. ([#365](https://github.com/terraform-compliance/cli/issues/365) [#273](https://github.com/terraform-compliance/cli/issues/273) [#381](https://github.com/terraform-compliance/cli/issues/381) [MicrosoftDocs/azure-dev-docs#396](https://github.com/MicrosoftDocs/azure-dev-docs/pull/396) [documentation](https://terraform-compliance.com/pages/usage/#-tv---terraform-version))
* Updated the hashicorp public key. ([#475](https://github.com/terraform-compliance/cli/issues/475))
* Fixed a problem where child_modules where not parsed in the plan file. ([#478](https://github.com/terraform-compliance/cli/issues/478))

## 1.3.15 (2020-05-12)
* Fixed an issue where [exclude resources tag](https://terraform-compliance.com/pages/bdd-references/using_tags.html#exclude-resources) were breaking due to improper `step_obj` creation from `Given` step. ([#468](https://github.com/terraform-compliance/cli/issues/468))
Expand Down
14 changes: 9 additions & 5 deletions terraform_compliance/common/terraform_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ def download_terraform(version):


def detect_required_terraform_version(string):
match = re.search(r'([0-9.]+), but this is ([0-9.]+); plan files cannot be transferred between',
string, re.DOTALL)

if match is not None:
return match.group(1), match.group(2)
match_regex = [
r'([0-9.]+), but this is ([0-9.]+); plan files cannot be transferred between',
r'by Terraform v([0-9.]+), which is newer than current v([0-9.]+);'
]
for pattern in match_regex:
match = re.search(pattern, string, re.DOTALL)

if match is not None:
return match.group(1), match.group(2)

return None, None

0 comments on commit 04978f0

Please sign in to comment.