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 fmt: add .tfmock.hcl as a supported file extension #34580

Merged

Conversation

HenriBlacksmith
Copy link
Contributor

@HenriBlacksmith HenriBlacksmith commented Jan 26, 2024

Fixes #34577

@hashicorp-cla
Copy link

hashicorp-cla commented Jan 26, 2024

CLA assistant check
All committers have signed the CLA.

@HenriBlacksmith HenriBlacksmith marked this pull request as draft January 26, 2024 16:19
@HenriBlacksmith HenriBlacksmith marked this pull request as ready for review January 26, 2024 16:41
@HenriBlacksmith
Copy link
Contributor Author

@liamcervante the suggested fix for #34577 is ready to be reviewed.

I added some test cases using mock AWS data sources and resources (I saw many already in the tests)

@liamcervante
Copy link
Member

Hi @HenriBlacksmith, the implementation and the new test cases look fine to me. Thanks so much for putting this together.

I just noticed, however, that the new test cases aren't actually executing. If you look at the test file you can see it's only checking things with the .tftest.hcl extension specifically: https://github.com/hashicorp/terraform/blob/main/internal/command/fmt_test.go#L20-L22

I didn't notice this before, so I can take full responsibility for it being missed here. But, could you copy the existing test case TestFmt_TestFiles, make a new one based on it called TestFmt_MockDataFiles or something similar, and then copy your new test files into a new directory tfmock-fmt or something similar, and then update the new test case to read the correct directory, and file extensions.

Hopefully that makes sense! Thanks again!

@HenriBlacksmith
Copy link
Contributor Author

Hi @HenriBlacksmith, the implementation and the new test cases look fine to me. Thanks so much for putting this together.

I just noticed, however, that the new test cases aren't actually executing. If you look at the test file you can see it's only checking things with the .tftest.hcl extension specifically: https://github.com/hashicorp/terraform/blob/main/internal/command/fmt_test.go#L20-L22

I didn't notice this before, so I can take full responsibility for it being missed here. But, could you copy the existing test case TestFmt_TestFiles, make a new one based on it called TestFmt_MockDataFiles or something similar, and then copy your new test files into a new directory tfmock-fmt or something similar, and then update the new test case to read the correct directory, and file extensions.

Hopefully that makes sense! Thanks again!

Sure, will have a look at this and fix asap, thanks for checking this (I should have checked test results carefully)

@HenriBlacksmith
Copy link
Contributor Author

@liamcervante I added the new test case dedicated to .tfmock.hcl files, it should be better now (The test data changed a bit now that the formatter actually runs on them 😸 )

Copy link
Member

@liamcervante liamcervante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We will backport this into v1.7, so it should be released within 1.7.2. Thanks for your contribution!

@liamcervante liamcervante added the 1.7-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Jan 29, 2024
@liamcervante liamcervante merged commit 49663bf into hashicorp:main Jan 29, 2024
6 checks passed
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

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 contributions.
If you have 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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.7-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terraform fmt does not handle .tfmock.hcl files
4 participants