Skip to content
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

Merged
merged 6 commits into from
Nov 5, 2020

Conversation

bverhoeve
Copy link
Contributor

#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.

@hashicorp-cla
Copy link

hashicorp-cla commented Sep 19, 2020

CLA assistant check
All committers have signed the CLA.

@skorfmann
Copy link
Contributor

Awesome - thank you! I'll check it out locally.

Copy link
Contributor

@skorfmann skorfmann left a 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.

packages/cdktf-cli/bin/cmds/terraform-check.ts Outdated Show resolved Hide resolved
Comment on lines 5 to 17
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')))
Copy link
Contributor Author

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.

Copy link
Contributor

@skorfmann skorfmann left a 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!

@skorfmann skorfmann merged commit 3c7085e into hashicorp:master Nov 5, 2020
@skorfmann skorfmann mentioned this pull request Nov 5, 2020
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants