diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 864893c..8b95ac2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -27,7 +27,7 @@ pre-commit try-repo {-a} /path/to/local/pre-commit-opentofu/repo {hook_name} I.e. ```bash -pre-commit try-repo /mnt/c/Users/tf/pre-commit-opentofu terraform_fmt # Run only `terraform_fmt` check +pre-commit try-repo /mnt/c/Users/tf/pre-commit-opentofu tofu_fmt # Run only `tofu_fmt` check pre-commit try-repo -a ~/pre-commit-opentofu # run all existing checks from repo ``` @@ -35,10 +35,10 @@ Running `pre-commit` with `try-repo` ignores all arguments specified in `.pre-co If you need to test hook with arguments, follow [pre-commit doc](https://pre-commit.com/#arguments-pattern-in-hooks) to test hooks. -For example, to test that the [`terraform_fmt`](../README.md#terraform_fmt) hook works fine with arguments: +For example, to test that the [`tofu_fmt`](../README.md#tofu_fmt) hook works fine with arguments: ```bash -/tmp/pre-commit-opentofu/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf +/tmp/pre-commit-opentofu/tofu_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf ``` ## Run hook performance test diff --git a/.github/ISSUE_TEMPLATE/bug_report_local_install.md b/.github/ISSUE_TEMPLATE/bug_report_local_install.md index 26deddd..7f17daf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_local_install.md +++ b/.github/ISSUE_TEMPLATE/bug_report_local_install.md @@ -78,7 +78,7 @@ Linux DESKTOP-C7315EF 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 bash << EOF bash --version | head -n 1 2>/dev/null || echo "bash SKIPPED" pre-commit --version 2>/dev/null || echo "pre-commit SKIPPED" -terraform --version | head -n 1 2>/dev/null || echo "terraform SKIPPED" +tofu --version | head -n 1 2>/dev/null || echo "tofu SKIPPED" python --version 2>/dev/null || echo "python SKIPPED" python3 --version 2>/dev/null || echo "python3 SKIPPED" echo -n "checkov " && checkov --version 2>/dev/null || echo "checkov SKIPPED" diff --git a/hooks/_common.sh b/hooks/_common.sh index e2dc924..e1a7c48 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -25,7 +25,7 @@ function common::initialize { # Globals (init and populate): # ARGS (array) arguments that configure wrapped tool behavior # HOOK_CONFIG (array) arguments that configure hook behavior -# TF_INIT_ARGS (array) arguments for `terraform init` command +# TF_INIT_ARGS (array) arguments for `tofu init` command # ENV_VARS (array) environment variables will be available # for all 3rd-party tools executed by a hook. # FILES (array) filenames to check diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 9be2808..2b37982 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -64,37 +64,38 @@ function terraform_docs_ { elif [[ "$hack_terraform_docs" == "1" ]]; then # Using awk script because terraform-docs is older than 0.8 and terraform 0.12 is used if [[ ! $(command -v awk) ]]; then + # TODO: pls check it echo "ERROR: awk is required for terraform-docs hack to work with Terraform 0.12." exit 1 fi local tmp_file_awk - tmp_file_awk=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") - terraform_docs_awk "$tmp_file_awk" - terraform_docs "$tmp_file_awk" "${configs[*]}" "$args" "${files[@]}" + tmp_file_awk=$(mktemp "${TMPDIR:-/tmp}/tofu-docs-XXXXXXXXXX") + tofu_docs_awk "$tmp_file_awk" + tofu_docs "$tmp_file_awk" "${configs[*]}" "$args" "${files[@]}" rm -f "$tmp_file_awk" else # Using terraform 0.11 and no awk script is needed for that - - terraform_docs "0" "${configs[*]}" "$args" "${files[@]}" + # TODO: should be deleted for OpenTofu. + tofu_docs "0" "${configs[*]}" "$args" "${files[@]}" fi } ####################################################################### # Wrapper around `terraform-docs` tool that check and change/create -# (depends on provided hook_config) terraform documentation in +# (depends on provided hook_config) OpenTofu documentation in # markdown format # Arguments: # terraform_docs_awk_file (string) filename where awk hack for old # `terraform-docs` was written. Needed for TF 0.12+. -# Hack skipped when `terraform_docs_awk_file == "0"` +# Hack skipped when `tofu_docs_awk_file == "0"` # hook_config (string with array) arguments that configure hook behavior # args (string with array) arguments that configure wrapped tool behavior # files (array) filenames to check ####################################################################### -function terraform_docs { - local -r terraform_docs_awk_file="$1" +function tofu_docs { + local -r tofu_docs_awk_file="$1" local -r hook_config="$2" local args="$3" shift 3 @@ -229,7 +230,7 @@ function terraform_docs { else # Can't append extension for mktemp, so renaming instead local tmp_file_docs - tmp_file_docs=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") + tmp_file_docs=$(mktemp "${TMPDIR:-/tmp}/tofu-docs-XXXXXXXXXX") mv "$tmp_file_docs" "$tmp_file_docs.tf" local tmp_file_docs_tf tmp_file_docs_tf="$tmp_file_docs.tf" @@ -263,7 +264,7 @@ function terraform_docs { # Arguments: # output_file (string) filename where hack will be written to ####################################################################### -function terraform_docs_awk { +function tofu_docs_awk { local -r output_file=$1 cat << "EOF" > "$output_file"