-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find
has an option to lookup files with particular names (or by a pattern), hencegrep
is extraneous and redundant here (as a side note,-E
meansgrep
should 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.md
files then?
@@ -62,6 +62,7 @@ If you are using `pre-commit-terraform` already or want to support its developme | |||
* [`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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
x
into 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