From 2601455ec17abf7e45566efe7c99ae3aecf76e66 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Fri, 6 Jun 2025 02:43:22 +0300 Subject: [PATCH 1/7] fix(`terraform_docs`, `terraform_wrapper_module_for_each`): Improve .tofu support Co-authored-by: T. Hinrichsmeyer --- hooks/terraform_docs.sh | 2 +- hooks/terraform_wrapper_module_for_each.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 6213fda08..34b526cde 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f | sed 's|.*\.||' | sort -u | grep -oE '^tf$|^tfvars$' || + find . -maxdepth 1 -type f | sed 's|.*\.||' | sort -u | grep -oE '^tf$|^tofu$|^tfvars$' || exit 0 )" diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/terraform_wrapper_module_for_each.sh index 945bf9a8a..172be6ec7 100755 --- a/hooks/terraform_wrapper_module_for_each.sh +++ b/hooks/terraform_wrapper_module_for_each.sh @@ -312,10 +312,10 @@ EOF # Read content of all terraform files # shellcheck disable=SC2207 - all_tf_content=$(find "${full_module_dir}" -name '*.tf' -maxdepth 1 -type f -exec cat {} +) + all_tf_content=$(find "${full_module_dir}" -regex '.*\.(tf|tofu)' -maxdepth 1 -type f -exec cat {} +) if [[ ! $all_tf_content ]]; then - common::colorify "yellow" "Skipping ${full_module_dir} because there are no *.tf files." + common::colorify "yellow" "Skipping ${full_module_dir} because there are no .tf or .tofu files." continue fi From cb6a120178b399b2b8bac22aeca4bd836a84799d Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 13:51:02 +0300 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- hooks/terraform_docs.sh | 2 +- hooks/terraform_wrapper_module_for_each.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 34b526cde..da06d40e8 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f | sed 's|.*\.||' | sort -u | grep -oE '^tf$|^tofu$|^tfvars$' || + find . -maxdepth 1 \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || exit 0 )" diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/terraform_wrapper_module_for_each.sh index 172be6ec7..f0f0d9f90 100755 --- a/hooks/terraform_wrapper_module_for_each.sh +++ b/hooks/terraform_wrapper_module_for_each.sh @@ -312,7 +312,7 @@ EOF # Read content of all terraform files # shellcheck disable=SC2207 - all_tf_content=$(find "${full_module_dir}" -regex '.*\.(tf|tofu)' -maxdepth 1 -type f -exec cat {} +) + all_tf_content=$(find "${full_module_dir}" \( -name '*.tf' -o -name '*.tofu' \) -maxdepth 1 -type f -exec cat {} +) if [[ ! $all_tf_content ]]; then common::colorify "yellow" "Skipping ${full_module_dir} because there are no .tf or .tofu files." From 7cef45d3c826589fd8ccc45585a14b90af1fb287 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 15:11:12 +0300 Subject: [PATCH 3/7] Update hooks/terraform_docs.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- 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 da06d40e8..698ed507e 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || + find . -maxdepth 1 -type f \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || exit 0 )" From c393834dd455da3e14ed50b2e1c79a36dddf45a5 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 15:12:08 +0300 Subject: [PATCH 4/7] 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 698ed507e..8c5ab0095 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || + find . -maxdepth 1 -type f \(-o -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || exit 0 )" From efb7311a99f10da5f08cb52ee511814749561a1b Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 15:13:07 +0300 Subject: [PATCH 5/7] 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 8c5ab0095..f4122f88f 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f \(-o -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || + find . -maxdepth 1 -type f \(-name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || exit 0 )" From f7a3fd6f420c9e41a0fcaa507db696b2c7bc1088 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 15:13:26 +0300 Subject: [PATCH 6/7] 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 f4122f88f..698ed507e 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f \(-name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || + find . -maxdepth 1 -type f \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || exit 0 )" From 70f018a5aaa8d433df9bdecab581d7ad69c47904 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 6 Jun 2025 15:51:42 +0300 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- hooks/terraform_docs.sh | 2 +- hooks/terraform_wrapper_module_for_each.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 698ed507e..02d012f83 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -207,7 +207,7 @@ function terraform_docs { # if $create_if_not_exist && [[ ! -f "$output_file" ]]; then dir_have_tf_files="$( - find . -maxdepth 1 -type f \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) || + find . -maxdepth 1 \( -name '*.tf' -o -name '*.tofu' -o -name '*.tfvars' \) -type f || exit 0 )" diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/terraform_wrapper_module_for_each.sh index f0f0d9f90..dc08b791c 100755 --- a/hooks/terraform_wrapper_module_for_each.sh +++ b/hooks/terraform_wrapper_module_for_each.sh @@ -312,7 +312,7 @@ EOF # Read content of all terraform files # shellcheck disable=SC2207 - all_tf_content=$(find "${full_module_dir}" \( -name '*.tf' -o -name '*.tofu' \) -maxdepth 1 -type f -exec cat {} +) + all_tf_content=$(find "${full_module_dir}" -maxdepth 1 \( -name '*.tf' -o -name '*.tofu' \) -type f -exec cat {} +) if [[ ! $all_tf_content ]]; then common::colorify "yellow" "Skipping ${full_module_dir} because there are no .tf or .tofu files."