feat: Add terrafmt hook#313
Conversation
| RUN . /.env && \ | ||
| if [ "TERRAFMT_VERSION" != "false" ]; then \ | ||
| ( \ | ||
| curl -L "https://github.com/katbyte/terrafmt/archive/refs/tags/v0.3.0.zip" > terrafmt.zip \ | ||
| ) && unzip terrafmt.zip && rm terrafmt.zip \ | ||
| ; fi |
There was a problem hiding this comment.
This block must follow common for this file convention/standard for this kind of blocks:
- Have a comment line right before the block with the name of the tool.
- Have a logic to distinguish which version to download.
Moreover the katbyte/terrafmt repo does not distribute pre-compiled binaries, which means the {zip,tar}ball contains source code rather than the executable file. From what I see in katbyte/terrafmt README, the only available option to install the tool at the moment is to build it locally or use Golang builtin mechanism to build and install. Which doesn't seem to be an acceptable approach for pre-commit-terraform at the moment (@antonbabenko @MaxymVlasov ?).
| @@ -0,0 +1,59 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
It might worth to pick up what @MaxymVlasov works on in #310 to modernize and standardize common shell coding conventions and approaches across hook scripts in this project.
| } | ||
|
|
||
| terrafmt_() { | ||
| find . | grep -E "README.md" | sort | while read -r f; do |
There was a problem hiding this comment.
findhas an option to lookup files with particular names (or by a pattern), hencegrepis extraneous and redundant here (as a side note,-Emeansgrepshould interpret pattern as an extended regex, which is redundant in this code construction).- Hook config is configured in this PR to pass all markdown files to the hook (
files: \.md$), so why would you need to pick onlyREADME.mdfiles then?
| * [`TFSec`](https://github.com/liamg/tfsec) required for `terraform_tfsec` hook. | ||
| * [`infracost`](https://github.com/infracost/infracost) required for `infracost_breakdown` hook. | ||
| * [`jq`](https://github.com/stedolan/jq) required for `infracost_breakdown` hook. | ||
| * [`terrafmt`](https://github.com/katbyte/terrafmt) required for `terraform_fmt` hook. |
There was a problem hiding this comment.
Please add needed installation instructions both for macOS and Ubuntu in the sections below.
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
Terrafmt hook
Terrafmt hook
update terrafmt documentation
|
This PR has been automatically marked as stale because it has been open 30 days |
|
This PR was automatically closed because of stale in 10 days |
|
@rahulmlokurte are you working on that PR? |
Put an
xinto the box if that apply:Description of your changes
Adding Terrafmt to format terraform embedded in the document. Referencing #256
How has this code been tested