From a703dda6939f5145e452f644b975859aca099e88 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Fri, 25 Nov 2022 19:30:01 +0200 Subject: [PATCH 1/2] fix: Describe migration instructions from `terraform_docs_replace` --- README.md | 51 +++++++++++++++++++++++++++++------------------ hooks/__init__.py | 2 +- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index f09c77402..712db4940 100644 --- a/README.md +++ b/README.md @@ -39,16 +39,16 @@ If you are using `pre-commit-terraform` already or want to support its developme * [All hooks: Usage of environment variables in `--args`](#all-hooks-usage-of-environment-variables-in---args) * [All hooks: Set env vars inside hook at runtime](#all-hooks-set-env-vars-inside-hook-at-runtime) * [All hooks: Disable color output](#all-hooks-disable-color-output) - * [checkov (deprecated) and terraform_checkov](#checkov-deprecated-and-terraform_checkov) - * [infracost_breakdown](#infracost_breakdown) - * [terraform_docs](#terraform_docs) - * [terraform_docs_replace (deprecated)](#terraform_docs_replace-deprecated) - * [terraform_fmt](#terraform_fmt) - * [terraform_providers_lock](#terraform_providers_lock) - * [terraform_tflint](#terraform_tflint) - * [terraform_tfsec](#terraform_tfsec) - * [terraform_validate](#terraform_validate) - * [terraform_wrapper_module_for_each](#terraform_wrapper_module_for_each) + * [checkov (deprecated) and terraform\_checkov](#checkov-deprecated-and-terraform_checkov) + * [infracost\_breakdown](#infracost_breakdown) + * [terraform\_docs](#terraform_docs) + * [terraform\_docs\_replace (deprecated)](#terraform_docs_replace-deprecated) + * [terraform\_fmt](#terraform_fmt) + * [terraform\_providers\_lock](#terraform_providers_lock) + * [terraform\_tflint](#terraform_tflint) + * [terraform\_tfsec](#terraform_tfsec) + * [terraform\_validate](#terraform_validate) + * [terraform\_wrapper\_module\_for\_each](#terraform_wrapper_module_for_each) * [terrascan](#terrascan) * [tfupdate](#tfupdate) * [Docker Usage: File Permissions](#docker-usage-file-permissions) @@ -498,18 +498,31 @@ Unlike most other hooks, this hook triggers once if there are any changed files ### terraform_docs_replace (deprecated) -**DEPRECATED**. Will be merged in [`terraform_docs`](#terraform_docs). See [#248](https://github.com/antonbabenko/pre-commit-terraform/issues/248) for details. +**DEPRECATED**. Will be merged in [`terraform_docs`](#terraform_docs). -`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 filename that gets created/modified. +`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. -Example: +To replicate functionality in `terraform_docs` hook: -```yaml -- id: terraform_docs_replace - args: - - --sort-by-required - - --dest=TEST.md -``` +1. Create `.terraform-docs.yml` in the repo root with the next context: + + ```yaml + formatter: "markdown" + + output: + file: "README.md" + mode: replace + template: |- + {{/** End of file fixer */}} + ``` + +2. Replace `terraform_docs_replace` hook config in `.pre-commit-config.yaml` with: + + ```yaml + - id: terraform_docs + args: + - --args=--config=.terraform-docs.yml + ``` ### terraform_fmt diff --git a/hooks/__init__.py b/hooks/__init__.py index ff01067a9..d026ae491 100644 --- a/hooks/__init__.py +++ b/hooks/__init__.py @@ -1,4 +1,4 @@ print( '`terraform_docs_replace` hook is DEPRECATED.' - 'For details, see https://github.com/antonbabenko/pre-commit-terraform/issues/248' + 'For migration instructions, see https://github.com/antonbabenko/pre-commit-terraform/issues/248#issuecomment-1290829226' ) From 2266ba847798fe0f60248100317ff08459bab30b Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 25 Nov 2022 20:27:23 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- README.md | 4 ++-- hooks/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 712db4940..ae6d3d98c 100644 --- a/README.md +++ b/README.md @@ -500,11 +500,11 @@ Unlike most other hooks, this hook triggers once if there are any changed files **DEPRECATED**. Will be merged in [`terraform_docs`](#terraform_docs). -`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. +`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. To replicate functionality in `terraform_docs` hook: -1. Create `.terraform-docs.yml` in the repo root with the next context: +1. Create `.terraform-docs.yml` in the repo root with the following content: ```yaml formatter: "markdown" diff --git a/hooks/__init__.py b/hooks/__init__.py index d026ae491..aeb6f9b27 100644 --- a/hooks/__init__.py +++ b/hooks/__init__.py @@ -1,4 +1,4 @@ print( '`terraform_docs_replace` hook is DEPRECATED.' - 'For migration instructions, see https://github.com/antonbabenko/pre-commit-terraform/issues/248#issuecomment-1290829226' + 'For migration instructions see https://github.com/antonbabenko/pre-commit-terraform/issues/248#issuecomment-1290829226' )