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

Switch to file directory for terraform-fmt check #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tonyo
Copy link

@tonyo tonyo commented May 9, 2023

Description

Problem

When using tfenv, terraform executable might resolve to different Terraform versions, depending on the directory where it runs (e.g. via using .terraform-version files).
At the moment, the terraform-fmt check runs terraform fmt from the repository root, and in some cases (e.g. when all Terraform configuration along with .terraform-version is in a subfolder) it might even mean that no valid Terraform version is configured.

Proposed solution

For terraform-fmt check, switch to the directory of the Terraform file we're checking (similarly to what happens in terraform-hclfmt and terraform-validate checks). This will ensure that the right Terraform version is picked up if tools like tfenv are used.

Documentation

TODOs

Please ensure all of these TODOs are completed before asking for a review.

  • Ensure the branch is named correctly with the issue number. e.g: feature/new-vpc-endpoints-955 or bug/missing-count-param-434.
  • Update the docs.
  • Keep the changes backward compatible where possible.
  • Run the pre-commit checks successfully.
  • Run the relevant tests successfully.

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant