Skip to content

Commit 56696a0

Browse files
mrwacky42antonbabenkobrainsikrobinbowesmetmajer
authored
rebase to upstream (#16)
* Added terraform-docs integration (#13) * Add hook to create readme * Updated README * Run terraform_docs only if README.md is present * Run terraform_docs only if README.md is present * Fixes use of md5 for tempfile name (#16) * Replace terraform_docs use of GNU sed with perl (#15) * Fix ShellCheck warning 2219 https://github.com/koalaman/shellcheck/wiki/SC2219 * Replace GNU sed commands with perl This replaces the sed commands which required GNU sed be installed with perl versions. This should make this script more universally usable (e.g., on macOS) without installing additional tools. * Only run validate if .tf files exist in the directory. (antonbabenko#20) * Only run validate if .tf files exist in the directory. * Same fix, different script :) * Updated README * Added license file (fixed antonbabenko#21) * Add feature to pass options to terraform-docs. * Added followup after antonbabenko#25 * Add new hook for running terraform-docs with replacing README.md from doc in main.tf * Address requested changes * Add `--dest` argument * Address requested changes * fix typo * Fix bug not letting terraform_docs_replace work in the root directory of a repo * Require terraform-docs runs in serial to avoid pre-commit doing parallel operations on similar file paths * Added chglog (hi @robinbowes :)) * Added CHANGELOG.md * Add exit code for 'terraform validate' so pre-commit check fails (antonbabenko#34) * Bump new version * fix check for errors at the end (antonbabenko#35) * Updated changelog * Update README.md (antonbabenko#36) * Fixed broken "maintained badge" * Added note about incompatibility of terraform-docs with Terraform 0.12 (antonbabenko#41) * Updated CHANGELOG * Added support for terraform_docs for Terraform 0.12 (antonbabenko#45) * Updated CHANGELOG * Upgraded to work with Terraform >= 0.12 (antonbabenko#44) * Updated CHANGELOG * Fix version in README.md (antonbabenko#46) * Fixed awk script for terraform-docs (kudos @cytopia) and mktemp on Mac (closes antonbabenko#47, antonbabenko#48, antonbabenko#49) * Updated CHANGELOG * Add slash to mktemp dir (fixed antonbabenko#50) * Updated CHANGELOG * Fix typo in README (antonbabenko#51) * Fixed enquoted types in terraform_docs (fixed antonbabenko#52) * Updated CHANGELOG * Formatter for Terragrunt HCL files (antonbabenko#60) * Formatter for Terragrunt HCL files * Adding Terragrunt documentation * Updated README with terragrunt_fmt hook * Updated CHANGELOG * Added support for TFLint with --deep parameter (antonbabenko#53) Added support for TFLint (https://github.com/wata727/tflint). Signed-off-by: Costin Galan <[email protected]> * Updated README with terraform_tflint hook * Updated CHANGELOG * Update rev in README.md (antonbabenko#70) Updating the version in the README. In order for `terraform_tflint`, the rev must be at least `v1.19.0`. * Improve installation instructions and make README more readable (antonbabenko#72) * Added FUNDING.yml * Fixes antonbabenko#65: terraform-docs should not fail if complex types contain 'description' keyword (antonbabenko#73) * Updated CHANGELOG * use getopt for args in the tflint hook, following the approach in terraform-docs (antonbabenko#75) * Updated CHANGELOG * move terraform-docs args after markdown command (antonbabenko#83) * Updated CHANGELOG * Added support for terraform-docs 0.8.0 with proper support for Terraform 0.12 syntax (bye-bye awk) (antonbabenko#85) * Updated CHANGELOG * Added shfmt to autoformat shell scripts (antonbabenko#86) * Updated CHANGELOG * Fixed tflint hook to iterate over files (antonbabenko#77) * Updated CHANGELOG * Fixed exit code for terraform 0.11 branch in terraform_docs (antonbabenko#94) * Updated pre-commit-hooks * Updated CHANGELOG * corrected tflint documentation (antonbabenko#95) * Updated CHANGELOG * Update installation instructions (antonbabenko#79) - Fix package name misspell - TFlint migrate to another organization * Allow passing multiple args to terraform-docs (antonbabenko#98) * Updated CHANGELOG * fix: Change terraform_validate hook functionality for subdirectories with terraform files (antonbabenko#100) * Update terraform_validate.sh: -Change to the directory before running terraform validate to use the Terraform configuration for the appropriate working directory. * Neglected to change the terraform validate call to use the default of the current directory. * Several changes to improve functionality: - Switch to checking the path for '*.tf' instead of always checking the current directory. - Try to find a '.terraform' directory (which indicates a `terraform init`) and change to that directory before running `terraform validate`. * Fix the description for the terraform_validate hook to reflect changes that were made in: antonbabenko@35e0356 * - Clean up comments. - Adjust variable names to better reflect what they are holding. * Updated CHANGELOG * feat: Support for TFSec (antonbabenko#103) * Updated pre-commit deps * Updated CHANGELOG * docs: Added coreutils as requirements in README.md (antonbabenko#105) * docs: Fixed the docs to use the latest config syntax(antonbabenko#106) * fix: Updated formatting in README (closes antonbabenko#113) * Updated CHANGELOG * feat: add terragrunt validate hook (antonbabenko#134) * Updated CHANGELOG * docs: Update terraform-docs link pointing to new organization (antonbabenko#130) * fix: Pass args and env vars to terraform validate (antonbabenko#125) * Updated CHANGELOG * chore: Use lib_getopt for all hooks and some style tweaks (antonbabenko#137) * Updated CHANGELOG * fix: Squash terraform_docs bug (antonbabenko#138) * Updated CHANGELOG * feat: have option for terraform_tfsec hook to only run in relevant modified directories (antonbabenko#135) * Updated CHANGELOG * fix: make terraform_tfsec.sh executable (antonbabenko#140) * Updated CHANGELOG * fix: Correctly handle arrays in terraform_docs.sh (antonbabenko#141) * Updated CHANGELOG * feat: Add checkov support (antonbabenko#143) * Updated CHANGELOG * feat: Add possibility to share tflint config file for subdirs (antonbabenko#149) * Updated CHANGELOG * fix: terraform-docs version 0.10 removed with-aggregate-type-defaults (antonbabenko#150) * Updated CHANGELOG * fix: make terraform_docs Windows compatible (antonbabenko#129) * Updated CHANGELOG * fix: Fix regex considering terraform-docs v0.10.0 old (antonbabenko#151) * Updated CHANGELOG * feat: Make terraform_validate to run init if necessary (antonbabenko#158) * Updated CHANGELOG * fix: Correct deprecated parameter to terraform-docs (antonbabenko#156) * Updated CHANGELOG * update to upstream hooks * just report, do not error * fix: Terraform validate for submodules (antonbabenko#172) * Updated CHANGELOG * docs: updates installs for macOS and ubuntu (antonbabenko#175) * fix: remove sed postprocessing from the terraform_docs_replace hook to fix compatibility with terraform-docs 0.11.0+ (antonbabenko#176) * Updated CHANGELOG * docs: Added checkov install (antonbabenko#182) * chore: add dockerfile (antonbabenko#183) * Updated CHANGELOG * Update README.md * chore: Fix mistake on command (antonbabenko#185) * fix: Fix and pin versions in Dockerfile (antonbabenko#193) * Updated CHANGELOG * feat: Adds support for Terrascan (antonbabenko#195) * Updated CHANGELOG * chore: Update Ubuntu install method (antonbabenko#198) * docs: Initial docs improvement (antonbabenko#218) * fix: Dockerized pre-commit-terraform (antonbabenko#219) Co-authored-by: Anton Babenko <[email protected]> * feat: Add mixed line ending check to prevent possible errors (antonbabenko#221) * feat: Add GH checks and templates (antonbabenko#222) * chore: Updated GH stale action config (antonbabenko#223) * fix: label auto-adding after label rename (antonbabenko#226) * fix: trigger terraform-docs on changes in lock files (antonbabenko#228) * Updated CHANGELOG * fix: remove dead code from terraform-docs script (antonbabenko#229) * chore: Add shfmt to workflow (antonbabenko#231) * docs: Describe hooks usage and improve examples (antonbabenko#232) Co-authored-by: Anton Babenko <[email protected]> * fix: Dockerfile if INSTALL_ALL is not defined (antonbabenko#233) * feat: Add PATH outputs when TFLint found any problem (antonbabenko#234) * fix: terraform_tflint hook executes in a serial way to run less often (antonbabenko#211) * docs: Add contributing guide and docs about performance tests (antonbabenko#235) * docs: Make contributors more visible (antonbabenko#236) * docs: Document terraform_tfsec args usage (antonbabenko#238) * feat: Add new hook for `terraform providers lock` operation (antonbabenko#173) * Updated CHANGELOG * chore: Do not mark issues and PR's in milestone as stale (antonbabenko#241) * fix: TFSec outputs the same results multiple times (antonbabenko#237) * docs: Add terraform_fmt usage instructions and how-to debug script with args (antonbabenko#242) * feat: Allow passing of args to terraform_fmt (antonbabenko#147) * docs: Document hooks dependencies (antonbabenko#247) * feat: Add support for specify terraform-docs config file (antonbabenko#244) * fix: terrafrom_tflint ERROR output for files located in repo root (antonbabenko#243) * feat: Add `terraform_docs` hook settings (antonbabenko#245) * docs: fix deps (antonbabenko#249) * fix: execute tflint once in no errors (antonbabenko#250) * fix: command not found (antonbabenko#251) * docs: Add missing space in terrascan install cmd (antonbabenko#253) * feat: add __GIT_WORKING_DIR__ to tfsec (antonbabenko#255) * docs: fix protocol to prevent MITM (antonbabenko#257) * feat: Set up PR reviewers automatically (antonbabenko#258) * feat: Add infracost_breakdown hook (antonbabenko#252) * docs: Clarify docs for terraform_tfsec hook (antonbabenko#266) * docs: Pre-release 1.53 (antonbabenko#267) * Updated CHANGELOG * fix: Fixed args expand in terraform_docs (antonbabenko#260) * docs: Added notes about sponsors (antonbabenko#268) * feat: Add support for quoted values in `infracost_breakdown` `--hook-config` (antonbabenko#269) * Updated CHANGELOG * fix: Fixed 1.54.0 where `terraform_docs` was broken (antonbabenko#272) * Updated CHANGELOG * chore: Updated messages shown in terraform_tflint hook (antonbabenko#274) * feat: Updated Docker image from Ubuntu to Alpine (antonbabenko#278) * Updated CHANGELOG * chore: Add deprecation notice to `terraform_docs_replace` (antonbabenko#280) * fix: typo in arg name for terraform-docs (antonbabenko#283) * Updated CHANGELOG * chore: Fix master merge to working branch on pre-commit autofixes (antonbabenko#286) * chore: Publish container image on release (antonbabenko#285) * Updated CHANGELOG * fix: Fixed docker build (antonbabenko#288) * Updated CHANGELOG * fix: pre-build docker image (antonbabenko#292) * Updated CHANGELOG * fix: analyse all folders with tflint and don't stop on first execution (antonbabenko#289) * feat: Pass custom arguments to terraform init in `terraform_validate` hook (antonbabenko#293) * Updated CHANGELOG * feat: Added semantic release (antonbabenko#296) * chore(release): version 1.62.0 [skip ci] # [1.62.0](antonbabenko/pre-commit-terraform@v1.61.0...v1.62.0) (2021-12-12) ### Features * Added semantic release ([antonbabenko#296](antonbabenko#296)) ([1bcca44](antonbabenko@1bcca44)) * chore: Validate PR title (antonbabenko#297) * chore: Updated validation PR title types (antonbabenko#298) * chore: Fixed allowed types for PR titles * chore: Publish container image only after the release * fix(terraform_tflint): Restore current working directory behavior (antonbabenko#302) * chore: Use valid token for the Release GHA * chore(release): version 1.62.1 [skip ci] ## [1.62.1](antonbabenko/pre-commit-terraform@v1.62.0...v1.62.1) (2021-12-18) ### Bug Fixes * **terraform_tflint:** Restore current working directory behavior ([antonbabenko#302](antonbabenko#302)) ([93029dc](antonbabenko@93029dc)) * fix: Properly exclude .terraform directory with checkov hook (antonbabenko#306) * fix: Speedup `terrascan` hook up to x3 times in big repos (antonbabenko#307) * chore: Release action should track hooks configuration changes (antonbabenko#308) * chore(release): version 1.62.2 [skip ci] ## [1.62.2](antonbabenko/pre-commit-terraform@v1.62.1...v1.62.2) (2021-12-21) ### Bug Fixes * Properly exclude .terraform directory with checkov hook ([antonbabenko#306](antonbabenko#306)) ([b431a43](antonbabenko@b431a43)) * Speedup `terrascan` hook up to x3 times in big repos ([antonbabenko#307](antonbabenko#307)) ([2e8dcf9](antonbabenko@2e8dcf9)) * fix: Check all directories with changes and pass all args in terrascan hook (antonbabenko#305) * chore(release): version 1.62.3 [skip ci] ## [1.62.3](antonbabenko/pre-commit-terraform@v1.62.2...v1.62.3) (2021-12-22) ### Bug Fixes * Check all directories with changes and pass all args in terrascan hook ([antonbabenko#305](antonbabenko#305)) ([66401d9](antonbabenko@66401d9)) * chore: Refactor all hooks (antonbabenko#310) * chore: Cleanup file with test data (antonbabenko#311) * chore: Add shellcheck and make checks passing (antonbabenko#315) Co-authored-by: Anton Babenko <[email protected]> * chore: Improved code structure (moved hooks into a separate dir) (antonbabenko#316) * chore: Specify what we exactly mean (antonbabenko#320) * chore: Document functions (based on google style guide) (antonbabenko#317) * chore: Add hadolint check for Dockerfiles (antonbabenko#322) Co-authored-by: Balazs Hamorszky <[email protected]> * chore: Add Github Actions Workflow to build if Dockerfile updated (antonbabenko#318) Co-authored-by: Maksym Vlasov <[email protected]> * docs: Add workaround for configuration_aliases tf bug (antonbabenko#332) * chore: fix bug intoduced in antonbabenko#316 (antonbabenko#335) * feat: Improve performance during `pre-commit --all (-a)` run (antonbabenko#327) * chore(release): version 1.63.0 [skip ci] # [1.63.0](antonbabenko/pre-commit-terraform@v1.62.3...v1.63.0) (2022-02-10) ### Features * Improve performance during `pre-commit --all (-a)` run ([antonbabenko#327](antonbabenko#327)) ([7e7c916](antonbabenko@7e7c916)) * feat: Improved speed of `pre-commit run -a` for multiple hooks (antonbabenko#338) * chore(release): version 1.64.0 [skip ci] # [1.64.0](antonbabenko/pre-commit-terraform@v1.63.0...v1.64.0) (2022-02-10) ### Features * Improved speed of `pre-commit run -a` for multiple hooks ([antonbabenko#338](antonbabenko#338)) ([579dc45](antonbabenko@579dc45)) * chore: Fix docker test workflow (antonbabenko#340) * chore: Add Docker latest and nightly tag (antonbabenko#343) Co-authored-by: Anton Babenko <[email protected]> Co-authored-by: jeremy avnet <[email protected]> Co-authored-by: Robin Bowes <[email protected]> Co-authored-by: Martin Etmajer <[email protected]> Co-authored-by: rothandrew <[email protected]> Co-authored-by: Chris Gilmer <[email protected]> Co-authored-by: Josiah Halme <[email protected]> Co-authored-by: Tyler Christiansen <[email protected]> Co-authored-by: Guido Dobboletta <[email protected]> Co-authored-by: Paweł Szczepaniak <[email protected]> Co-authored-by: Leonhardt Wille <[email protected]> Co-authored-by: Eric Gonzales <[email protected]> Co-authored-by: Scott Crooks <[email protected]> Co-authored-by: Costin GALAN <[email protected]> Co-authored-by: Dave Gallant <[email protected]> Co-authored-by: Maksym Vlasov <[email protected]> Co-authored-by: cytopia <[email protected]> Co-authored-by: chopped pork <[email protected]> Co-authored-by: Thierno IB. BARRY <[email protected]> Co-authored-by: Konstantin Kirpichnikov <[email protected]> Co-authored-by: Robson Roberto Souza Peixoto <[email protected]> Co-authored-by: Martin Coxall <[email protected]> Co-authored-by: Sergei Ivanov <[email protected]> Co-authored-by: Nick M <[email protected]> Co-authored-by: Jon Proietti <[email protected]> Co-authored-by: gchappell99 <[email protected]> Co-authored-by: snolan-uturn <[email protected]> Co-authored-by: Prahalad Ramji <[email protected]> Co-authored-by: Khosrow Moossavi <[email protected]> Co-authored-by: nkazarian-spokeo <[email protected]> Co-authored-by: Matias Zilli <[email protected]> Co-authored-by: Evan Stoddard <[email protected]> Co-authored-by: Shawn <[email protected]> Co-authored-by: Manuel Vogel <[email protected]> Co-authored-by: Sergio Kef <[email protected]> Co-authored-by: Cesar Rodriguez <[email protected]> Co-authored-by: Lorenz Vanthillo <[email protected]> Co-authored-by: balihb <[email protected]> Co-authored-by: Javier Collado <[email protected]> Co-authored-by: Dan Arnold <[email protected]> Co-authored-by: gravitybacklight <[email protected]> Co-authored-by: Milos Jajac <[email protected]> Co-authored-by: Birger J. Nordølum <[email protected]> Co-authored-by: sg70 <[email protected]> Co-authored-by: Bruno Ferreira <[email protected]> Co-authored-by: Maxime Brunet <[email protected]> Co-authored-by: semantic-release-bot <[email protected]> Co-authored-by: Maxime Brunet <[email protected]> Co-authored-by: Carlos Miguel Bustillo Rodríguez <[email protected]> Co-authored-by: Mohit Saxena <[email protected]> Co-authored-by: Mark Bainter <[email protected]> Co-authored-by: Pasquale De Vita <[email protected]>
1 parent d5a3b61 commit 56696a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4432
-214
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.dockerignore
3+
!Dockerfile

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[{*.{py,md},Dockerfile}]
11+
indent_size = 4
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @maxymvlasov @yermulnik

.github/CONTRIBUTING.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Notes for contributors
2+
3+
1. Python hooks are supported now too. All you have to do is:
4+
1. add a line to the `console_scripts` array in `entry_points` in `setup.py`
5+
2. Put your python script in the `pre_commit_hooks` folder
6+
7+
Enjoy the clean, valid, and documented code!
8+
9+
* [Run and debug hooks locally](#run-and-debug-hooks-locally)
10+
* [Run hook performance test](#run-hook-performance-test)
11+
* [Run via BASH](#run-via-bash)
12+
* [Run via Docker](#run-via-docker)
13+
* [Check results](#check-results)
14+
* [Cleanup](#cleanup)
15+
* [Add new hook](#add-new-hook)
16+
* [Before write code](#before-write-code)
17+
* [Prepare basic documentation](#prepare-basic-documentation)
18+
* [Add code](#add-code)
19+
* [Finish with the documentation](#finish-with-the-documentation)
20+
21+
## Run and debug hooks locally
22+
23+
```bash
24+
pre-commit try-repo {-a} /path/to/local/pre-commit-terraform/repo {hook_name}
25+
```
26+
27+
I.e.
28+
29+
```bash
30+
pre-commit try-repo /mnt/c/Users/tf/pre-commit-terraform terraform_fmt # Run only `terraform_fmt` check
31+
pre-commit try-repo -a ~/pre-commit-terraform # run all existing checks from repo
32+
```
33+
34+
Running `pre-commit` with `try-repo` ignores all arguments specified in `.pre-commit-config.yaml`.
35+
36+
If you need to test hook with arguments, follow [pre-commit doc](https://pre-commit.com/#arguments-pattern-in-hooks) to test hooks.
37+
38+
For example, to test that the [`terraform_fmt`](../README.md#terraform_fmt) hook works fine with arguments:
39+
40+
```bash
41+
/tmp/pre-commit-terraform/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf
42+
```
43+
44+
## Run hook performance test
45+
46+
To check is your improvement not violate performance, we have dummy execution time tests.
47+
48+
Script accept next options:
49+
<!-- markdownlint-disable no-inline-html -->
50+
| # | Name | Example value | Description |
51+
| --- | ---------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------- |
52+
| 1 | `TEST_NUM` | `200` | How many times need repeat test |
53+
| 2 | `TEST_COMMAND` | `'pre-commit try-repo -a /tmp/159/pre-commit-terraform terraform_tfsec'` | Valid pre-commit command |
54+
| 3 | `TEST_DIR` | `'/tmp/infrastructure'` | Dir on what you run tests. |
55+
| 4 | `TEST_DESCRIPTION` | ```'`terraform_tfsec` PR #123:'``` | Text that you'd like to see in result |
56+
| 5 | `RAW_TEST_`<br>`RESULTS_FILE_NAME` | `terraform_tfsec_pr123` | (Temporary) File where all test data will be stored. |
57+
<!-- markdownlint-enable no-inline-html -->
58+
59+
> **Note:** To make test results repeatable and comparable, be sure that on the test machine nothing generates an unstable workload. During tests good to stop any other apps and do not interact with the test machine.
60+
>
61+
> Otherwise, for eg, when you watch Youtube videos during one test and not during other, test results can differ up to 30% for the same test.
62+
63+
### Run via BASH
64+
65+
```bash
66+
# Install deps
67+
sudo apt install -y datamash
68+
# Run tests
69+
./hooks_performance_test.sh 200 'pre-commit try-repo -a /tmp/159/pre-commit-terraform terraform_tfsec' '/tmp/infrastructure' '`terraform_tfsec` v1.51.0:' 'terraform_tfsec_pr159'
70+
```
71+
72+
### Run via Docker
73+
74+
```bash
75+
# Build `pre-commit-terraform` image
76+
docker build -t pre-commit-terraform --build-arg INSTALL_ALL=true .
77+
# Build test image
78+
docker build -t pre-commit-tests tests/
79+
# Run
80+
TEST_NUM=1
81+
TEST_DIR='/tmp/infrastructure'
82+
PRE_COMMIT_DIR="$(pwd)"
83+
TEST_COMMAND='pre-commit try-repo -a /pct terraform_tfsec'
84+
TEST_DESCRIPTION='`terraform_tfsec` v1.51.0:'
85+
RAW_TEST_RESULTS_FILE_NAME='terraform_tfsec_pr159'
86+
87+
docker run -v "$PRE_COMMIT_DIR:/pct:rw" -v "$TEST_DIR:/lint:ro" pre-commit-tests \
88+
$TEST_NUM "$TEST_COMMAND" '/lint' "$RAW_TEST_RESULTS_FILE_NAME" "$RAW_TEST_RESULTS_FILE_NAME"
89+
```
90+
91+
### Check results
92+
93+
Results will be located at `./test/results` dir.
94+
95+
### Cleanup
96+
97+
```bash
98+
sudo rm -rf tests/results
99+
```
100+
101+
## Add new hook
102+
103+
You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/252) as an example.
104+
105+
### Before write code
106+
107+
1. Try to figure out future hook usage.
108+
2. Confirm the concept with [Anton Babenko](https://github.com/antonbabenko).
109+
110+
### Prepare basic documentation
111+
112+
1. Identify and describe dependencies in [Install dependencies](../README.md#1-install-dependencies) and [Available Hooks](../README.md#available-hooks) sections
113+
114+
### Add code
115+
116+
1. Based on prev. block, add hook dependencies installation to [Dockerfile](../Dockerfile).
117+
Check that works:
118+
* `docker build -t pre-commit --build-arg INSTALL_ALL=true .`
119+
* `docker build -t pre-commit --build-arg <NEW_HOOK>_VERSION=latest .`
120+
* `docker build -t pre-commit --build-arg <NEW_HOOK>_VERSION=<1.2.3> .`
121+
2. Add new hook to [`.pre-commit-hooks.yaml`](../.pre-commit-hooks.yaml)
122+
3. Create hook file. Don't forget to make it executable via `chmod +x /path/to/hook/file`.
123+
4. Test hook. How to do it is described in [Run and debug hooks locally](#run-and-debug-hooks-locally) section.
124+
5. Test hook one more time.
125+
1. Push commit with hook file to GitHub
126+
2. Grab SHA hash of the commit
127+
3. Test hook using `.pre-commit-config.yaml`:
128+
129+
```yaml
130+
repos:
131+
- repo: https://github.com/antonbabenko/pre-commit-terraform # Your repo
132+
rev: 3d76da3885e6a33d59527eff3a57d246dfb66620 # Your commit SHA
133+
hooks:
134+
- id: terraform_docs # New hook name
135+
args:
136+
- --args=--config=.terraform-docs.yml # Some args that you'd like to test
137+
```
138+
139+
### Finish with the documentation
140+
141+
1. Add hook description to [Available Hooks](../README.md#available-hooks).
142+
2. Create and populate a new hook section in [Hooks usage notes and examples](../README.md#hooks-usage-notes-and-examples).

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [antonbabenko]
2+
custom: https://www.paypal.me/antonbabenko
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: Docker bug report
3+
about: Create a bug report
4+
labels:
5+
- bug
6+
- area/docker
7+
---
8+
9+
<!--
10+
Thank you for helping to improve pre-commit-terraform!
11+
12+
Please be sure to search for open issues before raising a new one. We use issues
13+
for bug reports and feature requests. Please note, this template is for bugs
14+
report, not feature requests.
15+
-->
16+
17+
### Describe the bug
18+
19+
<!--
20+
Please let us know what behavior you expected and how terraform-docs diverged
21+
from that behavior.
22+
-->
23+
24+
25+
### How can we reproduce it?
26+
27+
<!--
28+
Help us to reproduce your bug as succinctly and precisely as possible. Any and
29+
all steps or script that triggers the issue are highly appreciated!
30+
31+
Do you have long logs to share? Please use collapsible sections, that can be created via:
32+
33+
<details><summary>SECTION_NAME</summary>
34+
35+
```bash
36+
YOUR_LOG_HERE
37+
```
38+
39+
</details>
40+
-->
41+
42+
43+
### Environment information
44+
45+
* OS:
46+
47+
<!-- I.e.:
48+
OS: Windows 10
49+
OS: Win10 with Ubuntu 20.04 on WSL2
50+
OS: MacOS
51+
OS: Ubuntu 20.04
52+
-->
53+
54+
* `docker info`:
55+
56+
<details><summary><code>command output</summary>
57+
58+
```bash
59+
INSERT_OUTPUT_HERE
60+
```
61+
62+
</details>
63+
64+
* Docker image tag/git commit:
65+
66+
* Tools versions. Don't forget to specify right tag in command -
67+
`TAG=latest && docker run --entrypoint cat pre-commit:$TAG /usr/bin/tools_versions_info`
68+
69+
```bash
70+
INSERT_OUTPUT_HERE
71+
```
72+
73+
* `.pre-commit-config.yaml`:
74+
75+
<details><summary>file content</summary>
76+
77+
```bash
78+
INSERT_FILE_CONTENT_HERE
79+
```
80+
81+
</details>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Local installation bug report
3+
about: Create a bug report
4+
labels:
5+
- bug
6+
- area/local_installation
7+
---
8+
9+
<!--
10+
Thank you for helping to improve pre-commit-terraform!
11+
12+
Please be sure to search for open issues before raising a new one. We use issues
13+
for bug reports and feature requests. Please note, this template is for bugs
14+
report, not feature requests.
15+
-->
16+
17+
### Describe the bug
18+
19+
<!--
20+
Please let us know what behavior you expected and how terraform-docs diverged
21+
from that behavior.
22+
-->
23+
24+
25+
### How can we reproduce it?
26+
27+
<!--
28+
Help us to reproduce your bug as succinctly and precisely as possible. Any and
29+
all steps or script that triggers the issue are highly appreciated!
30+
31+
Do you have long logs to share? Please use collapsible sections, that can be created via:
32+
33+
<details><summary>SECTION_NAME</summary>
34+
35+
```bash
36+
YOUR_LOG_HERE
37+
```
38+
39+
</details>
40+
-->
41+
42+
43+
### Environment information
44+
45+
* OS:
46+
<!-- I.e.:
47+
OS: Windows 10
48+
OS: Win10 with Ubuntu 20.04 on WSL2
49+
OS: MacOS
50+
OS: Ubuntu 20.04
51+
-->
52+
53+
* `uname -a` and/or `systeminfo | Select-String "^OS"` output:
54+
55+
```bash
56+
INSERT_OUTPUT_HERE
57+
```
58+
59+
<!-- I.e.:
60+
```bash
61+
PS C:\Users\vm> systeminfo | Select-String "^OS"
62+
63+
OS Name: Microsoft Windows 10 Pro
64+
OS Version: 10.0.19043 N/A Build 19043
65+
OS Manufacturer: Microsoft Corporation
66+
OS Configuration: Standalone Workstation
67+
OS Build Type: Multiprocessor Free
68+
69+
$ uname -a
70+
Linux DESKTOP-C7315EF 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
71+
```
72+
-->
73+
74+
* Tools availability and versions:
75+
76+
<!-- For check all needed version run next script:
77+
78+
$0 << EOF
79+
pre-commit --version 2>/dev/null || echo "pre-commit SKIPPED"
80+
terraform --version | head -n 1 2>/dev/null || echo "terraform SKIPPED"
81+
python --version 2>/dev/null || echo "python SKIPPED"
82+
python3 --version 2>/dev/null || echo "python3 SKIPPED"
83+
echo -n "checkov " && checkov --version 2>/dev/null || echo "checkov SKIPPED"
84+
terraform-docs --version 2>/dev/null || echo "terraform-docs SKIPPED"
85+
terragrunt --version 2>/dev/null || echo "terragrunt SKIPPED"
86+
echo -n "terrascan " && terrascan version 2>/dev/null || echo "terrascan SKIPPED"
87+
tflint --version 2>/dev/null || echo "tflint SKIPPED"
88+
echo -n "tfsec " && tfsec --version 2>/dev/null || echo "tfsec SKIPPED"
89+
EOF
90+
91+
-->
92+
93+
```bash
94+
INSERT_TOOLS_VERSIONS_HERE
95+
```
96+
97+
98+
* `.pre-commit-config.yaml`:
99+
100+
<details><summary>file content</summary>
101+
102+
```bash
103+
INSERT_FILE_CONTENT_HERE
104+
```
105+
106+
</details>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels:
5+
- feature
6+
---
7+
8+
<!--
9+
Thank you for helping to improve pre-commit-terraform!
10+
11+
Please be sure to search for open issues before raising a new one. We use issues
12+
for bug reports and feature requests. Please note, this template is for feature
13+
requests, not bugs report.
14+
-->
15+
16+
### What problem are you facing?
17+
18+
<!--
19+
Please tell us a little about your use case - it's okay if it's hypothetical!
20+
Leading with this context helps frame the feature request so we can ensure we
21+
implement it sensibly.
22+
--->
23+
24+
25+
### How could pre-commit-terraform help solve your problem?
26+
27+
<!--
28+
Let us know how you think pre-commit-terraform could help with your use case.
29+
-->

0 commit comments

Comments
 (0)