Skip to content

Commit

Permalink
fix: Correct deprecated parameter to terraform-docs (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolidano authored Nov 12, 2020
1 parent fe2d121 commit 3a07570
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform
| `terraform_validate` | Validates all Terraform configuration files. |
| `terraform_docs` | Inserts input and output documentation into `README.md`. Recommended. |
| `terraform_docs_without_aggregate_type_defaults` | Inserts input and output documentation into `README.md` without aggregate type defaults. |
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md |
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md (requires terraform-docs v0.10.0 or later) |
| `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). |
| `terragrunt_fmt` | Rewrites all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. |
| `terragrunt_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) |
Expand All @@ -91,13 +91,13 @@ Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blo
```
if they are present in `README.md`.

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.
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.

1. Example:
```yaml
hooks:
- id: terraform_docs_replace
args: ['--with-aggregate-type-defaults', '--sort-inputs-by-required', '--dest=TEST.md']
args: ['--sort-by-required', '--dest=TEST.md']
```
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.
Expand Down
9 changes: 6 additions & 3 deletions pre_commit_hooks/terraform_docs_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ def main(argv=None):
)
parser.add_argument(
'--sort-inputs-by-required', dest='sort', action='store_true',
help='[deprecated] use --sort-by-required instead',
)
parser.add_argument(
'--sort-by-required', dest='sort', action='store_true',
)
parser.add_argument(
'--with-aggregate-type-defaults', dest='aggregate', action='store_true',
help='[deprecated]',
)
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)
Expand All @@ -35,9 +40,7 @@ def main(argv=None):
procArgs = []
procArgs.append('terraform-docs')
if args.sort:
procArgs.append('--sort-inputs-by-required')
if args.aggregate:
procArgs.append('--with-aggregate-type-defaults')
procArgs.append('--sort-by-required')
procArgs.append('md')
procArgs.append("./{dir}".format(dir=dir))
procArgs.append("| sed -e '$ d' -e 'N;/^\\n$/D;P;D'")
Expand Down

0 comments on commit 3a07570

Please sign in to comment.