Skip to content

Commit 3a07570

Browse files
authored
fix: Correct deprecated parameter to terraform-docs (#156)
1 parent fe2d121 commit 3a07570

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform
7272
| `terraform_validate` | Validates all Terraform configuration files. |
7373
| `terraform_docs` | Inserts input and output documentation into `README.md`. Recommended. |
7474
| `terraform_docs_without_aggregate_type_defaults` | Inserts input and output documentation into `README.md` without aggregate type defaults. |
75-
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md |
75+
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md (requires terraform-docs v0.10.0 or later) |
7676
| `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). |
7777
| `terragrunt_fmt` | Rewrites all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. |
7878
| `terragrunt_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) |
@@ -91,13 +91,13 @@ Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blo
9191
```
9292
if they are present in `README.md`.
9393

94-
1. `terraform_docs_replace` replaces the entire README.md rather than doing string replacement between markers. Put your additional documentation at the top of your `main.tf` for it to be pulled in. The optional `--dest` argument lets you change the name of the file that gets created/modified.
94+
1. `terraform_docs_replace` replaces the entire README.md rather than doing string replacement between markers. Put your additional documentation at the top of your `main.tf` for it to be pulled in. The optional `--dest` argument lets you change the name of the file that gets created/modified. This hook requires terraform-docs v0.10.0 or later.
9595

9696
1. Example:
9797
```yaml
9898
hooks:
9999
- id: terraform_docs_replace
100-
args: ['--with-aggregate-type-defaults', '--sort-inputs-by-required', '--dest=TEST.md']
100+
args: ['--sort-by-required', '--dest=TEST.md']
101101
```
102102
103103
1. It is possible to pass additional arguments to shell scripts when using `terraform_docs` and `terraform_docs_without_aggregate_type_defaults`. Send pull-request with the new hook if there is something missing.

pre_commit_hooks/terraform_docs_replace.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ def main(argv=None):
1515
)
1616
parser.add_argument(
1717
'--sort-inputs-by-required', dest='sort', action='store_true',
18+
help='[deprecated] use --sort-by-required instead',
19+
)
20+
parser.add_argument(
21+
'--sort-by-required', dest='sort', action='store_true',
1822
)
1923
parser.add_argument(
2024
'--with-aggregate-type-defaults', dest='aggregate', action='store_true',
25+
help='[deprecated]',
2126
)
2227
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
2328
args = parser.parse_args(argv)
@@ -35,9 +40,7 @@ def main(argv=None):
3540
procArgs = []
3641
procArgs.append('terraform-docs')
3742
if args.sort:
38-
procArgs.append('--sort-inputs-by-required')
39-
if args.aggregate:
40-
procArgs.append('--with-aggregate-type-defaults')
43+
procArgs.append('--sort-by-required')
4144
procArgs.append('md')
4245
procArgs.append("./{dir}".format(dir=dir))
4346
procArgs.append("| sed -e '$ d' -e 'N;/^\\n$/D;P;D'")

0 commit comments

Comments
 (0)