From 21d7ca03b963413e3b41daf4a40727d6be2156e9 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Tue, 27 Aug 2024 20:56:34 +0300 Subject: [PATCH 1/5] feat(`terraform_docs`): Star seamless migration to terraform-docs markers --- README.md | 6 +++--- hooks/terraform_docs.sh | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 291f5ba06..54c91d3ae 100644 --- a/README.md +++ b/README.md @@ -581,8 +581,8 @@ Unlike most other hooks, this hook triggers once if there are any changed files * create a documentation file * extend existing documentation file by appending markers to the end of the file (see item 1 above) * use different filename for the documentation (default is `README.md`) - * use the same insertion markers as `terraform-docs` by default. It will be default in `v2.0`. - To migrate to `terraform-docs` insertion markers, run in repo root: + * use the same insertion markers as `terraform-docs` by default. It's default starting from `v1.93`. + To migrate everything to `terraform-docs` insertion markers, run in repo root: ```bash grep -rl 'BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i 's/BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/BEGIN_TF_DOCS/g' @@ -595,7 +595,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files - --hook-config=--path-to-file=README.md # Valid UNIX path. I.e. ../TFDOC.md or docs/README.md etc. - --hook-config=--add-to-existing-file=true # Boolean. true or false - --hook-config=--create-file-if-not-exist=true # Boolean. true or false - - --hook-config=--use-standard-markers=true # Boolean. Defaults in v1.x to false. Set to true for compatibility with terraform-docs + - --hook-config=--use-standard-markers=true # Boolean. Default to true (v1.93+), false ( /dev/null && continue + replace_old_markers "$text_file" + # # If `--add-to-existing-file=true` set, check is in file exist "hook markers", # and if not - append "hook markers" to the end of file. From e5209b3b0b27a5c7aea11aac86a93dfff1f0ac21 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Tue, 27 Aug 2024 21:13:52 +0300 Subject: [PATCH 2/5] Add deprecation warning --- README.md | 2 +- hooks/terraform_docs.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54c91d3ae..b234ba22b 100644 --- a/README.md +++ b/README.md @@ -581,7 +581,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files * create a documentation file * extend existing documentation file by appending markers to the end of the file (see item 1 above) * use different filename for the documentation (default is `README.md`) - * use the same insertion markers as `terraform-docs` by default. It's default starting from `v1.93`. + * use the same insertion markers as `terraform-docs`. It's default starting from `v1.93`. To migrate everything to `terraform-docs` insertion markers, run in repo root: ```bash diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 3f01795b7..ad6e0a9c9 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -162,6 +162,8 @@ function terraform_docs { ;; --use-standard-markers) use_standard_markers=$value + common::colorify "yellow" "WARNING: --use-standard-markers is deprecated and will be removed in the future." + common::colorify "yellow" " All needed changes already done by the hook, feel free to remove this line." ;; esac done From 6d420222c487fa060222b57384ead6290caf24dd Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Tue, 27 Aug 2024 21:33:11 +0300 Subject: [PATCH 3/5] Apply suggestions from code review --- hooks/terraform_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index ad6e0a9c9..929753fe7 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -169,7 +169,7 @@ function terraform_docs { done if [ "$use_standard_markers" = false ]; then - # update the insertion markers to those used by terraform-docs + # update the insertion markers to those used by pre-commit-terraform before v1.93 insertion_marker_begin="$old_insertion_marker_begin" insertion_marker_end="$old_insertion_marker_end" fi From 1f6a6185c66e6febee25e39673e8efeb9051accc Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Wed, 28 Aug 2024 15:40:19 +0300 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- README.md | 2 +- hooks/terraform_docs.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b234ba22b..b3abc8d21 100644 --- a/README.md +++ b/README.md @@ -595,7 +595,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files - --hook-config=--path-to-file=README.md # Valid UNIX path. I.e. ../TFDOC.md or docs/README.md etc. - --hook-config=--add-to-existing-file=true # Boolean. true or false - --hook-config=--create-file-if-not-exist=true # Boolean. true or false - - --hook-config=--use-standard-markers=true # Boolean. Default to true (v1.93+), false ( Date: Wed, 28 Aug 2024 20:04:21 +0300 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b3abc8d21..4c69a1b46 100644 --- a/README.md +++ b/README.md @@ -568,9 +568,9 @@ Unlike most other hooks, this hook triggers once if there are any changed files 1. `terraform_docs` and `terraform_docs_without_aggregate_type_defaults` will insert/update documentation generated by [terraform-docs](https://github.com/terraform-docs/terraform-docs) framed by markers: ```txt - + - + ``` if they are present in `README.md`.