Skip to content

Commit

Permalink
Merge branch 'master' into renovate/github-codeql-action-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxymVlasov authored Feb 5, 2025
2 parents e6ed4ad + 0dac002 commit 518cb29
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
steps:
- name: Switch to using Python 3.13 by default
# yamllint disable-line rule:line-length
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: 3.13
- name: Check out src from Git
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
steps:
- name: Switch to using Python 3.13
# yamllint disable-line rule:line-length
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: 3.13

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
# Skip terraform_tflint which interferes to commit pre-commit auto-fixes
# yamllint disable-line rule:line-length
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.9'
- name: Execute pre-commit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
by default
id: python-install
# yamllint disable-line rule:line-length
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ inputs.python-version }}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.97.3](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.97.2...v1.97.3) (2025-02-04)


### Bug Fixes

* **`terraform_docs`:** Fix bug introduced in `v1.97.2` ([#801](https://github.com/antonbabenko/pre-commit-terraform/issues/801)) ([64b81f4](https://github.com/antonbabenko/pre-commit-terraform/commit/64b81f449344ed72d180d57ce0a801389c018584)), closes [#796](https://github.com/antonbabenko/pre-commit-terraform/issues/796)

## [1.97.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.97.1...v1.97.2) (2025-02-03)


Expand Down
4 changes: 3 additions & 1 deletion hooks/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function common::initialize {
function common::parse_cmdline {
# common global arrays.
# Populated via `common::parse_cmdline` and can be used inside hooks' functions
ARGS=() HOOK_CONFIG=() FILES=()
ARGS=()
HOOK_CONFIG=()
FILES=()
# Used inside `common::terraform_init` function
TF_INIT_ARGS=()
# Used inside `common::export_provided_env_vars` function
Expand Down
23 changes: 17 additions & 6 deletions hooks/terraform_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function terraform_docs {
# `--hook-config=--path-to-file=` if it set
local config_output_file
# Get latest non-commented `output.file` from `.terraform-docs.yml`
config_output_file=$(grep -A1000 -e '^output:$' "$config_file" | grep -E '^[[:space:]]+file:' | tail -n 1) || true
config_output_file=$(grep -A1000 -e '^output:$' "$config_file" 2> /dev/null | grep -E '^[[:space:]]+file:' | tail -n 1) || true

if [[ $config_output_file ]]; then
# Extract filename from `output.file` line
Expand All @@ -176,7 +176,7 @@ function terraform_docs {

# Use `.terraform-docs.yml` `output.mode` if it set
local config_output_mode
config_output_mode=$(grep -A1000 -e '^output:$' "$config_file" | grep -E '^[[:space:]]+mode:' | tail -n 1) || true
config_output_mode=$(grep -A1000 -e '^output:$' "$config_file" 2> /dev/null | grep -E '^[[:space:]]+mode:' | tail -n 1) || true
if [[ $config_output_mode ]]; then
# Extract mode from `output.mode` line
output_mode=$(echo "$config_output_mode" | awk -F':' '{print $2}' | tr -d '[:space:]"' | tr -d "'")
Expand Down Expand Up @@ -240,10 +240,21 @@ function terraform_docs {
have_marker=$(grep -o "$insertion_marker_begin" "$output_file") || unset have_marker
[[ ! $have_marker ]] && popd > /dev/null && continue
fi
local config_options
[[ $have_config_flag == true ]] && config_options="--config=$config_file"
# shellcheck disable=SC2086
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter "$config_options" $args ./ > /dev/null

# shellcheck disable=SC2206
# Need to pass $tf_docs_formatter and $args as separate arguments, not as single string
local tfdocs_cmd=(
terraform-docs
--output-mode="$output_mode"
--output-file="$output_file"
$tf_docs_formatter
$args
)
if [[ $have_config_flag == true ]]; then
"${tfdocs_cmd[@]}" "--config=$config_file" ./ > /dev/null
else
"${tfdocs_cmd[@]}" ./ > /dev/null
fi

popd > /dev/null
done
Expand Down

0 comments on commit 518cb29

Please sign in to comment.