terraspace
terraspace copied to clipboard
[feature-request] terraspace fmt specific files
Summary
In #94, terraspace fmt
was added (🥳 ). Can this be further expanded upon to pass a list of files to run fmt
on, instead of the entire project? Something like this:
terraspace fmt stacks/project/main.tf stacks/gke/main.tf
Motivation
We are using a .pre-commit-config.yaml
to run certain things as a pre-commit hook to the project. We've added this into the mix to ensure our files are formatted. However, if we change one file, it runs on the entire project resulting in a long processing of our larger Terraspace projects.
If we could pass individual files, pre-commit-config
allows us to pass the staged files to the script being called. This would drastically improve pre-commit performance as it would only need to run on the files that were actually modified.
Note: I would submit a PR, but I am not familiar enough with Ruby and am hoping someone else has some bandwidth to cook this up. 🍻
Did a quick simple implementation that adds the ability to specify the module or stack name for now in #96
Think it can be improved as shown in the request:
terraspace fmt stacks/project/main.tf stacks/gke/main.tf
Will consider PRs to improve this. Of course, no sweat either way 👍 Otherwise, will dig into it in time ⏰
@tongueroo I'll see if I can take a stab at it over the weekend when the kids are napping. Be ready to see some bad Ruby code though. :D