-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform version check #378
Conversation
Awesome - thank you! I'll check it out locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bverhoeve sorry for the delay. I just tried it locally, and it doesn't seem to work as expected. See inline comment for more details.
const VERSION_REGEXP = /Terraform v\d+.\d+.\d+/ | ||
|
||
export const terraformCheck = async (): Promise<void> => { | ||
try { | ||
const terraform = new Terraform('./') | ||
await terraform.version() | ||
const terraform: Terraform = new Terraform('./') | ||
|
||
const terraformVersion = await terraform.version() | ||
const terraformVersionMatches = terraformVersion.match(VERSION_REGEXP) | ||
|
||
if ( terraformVersionMatches !== null) { | ||
|
||
// Should always be the first match found in the string | ||
let cleanTerraformVersion = semver.clean(terraformVersionMatches[0].substring(terraformVersionMatches[0].indexOf('v'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skorfmann I've explicitly parsed the string so it becomes something like Terraform v13.0.1
which can then be compared against by semver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet - looks good. Tried it locally and works as expected. Thank you!
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
#216
This is meant to reduce confusion to users running an older version of Terraform by printing out a warning notice when Terraform < 0.12. It could be extended in the future as well by printing a warning when a user is using a version higher than the minimally supported version.
I'm not entirely sure if the minimally supported version should be declared here or somewhere else.