Skip to content

fix(terraform_docs): Allow having whitespaces in path to .terraform-docs.yaml config file #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions hooks/terraform_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function terraform_docs {
local add_to_existing=false
local create_if_not_exist=false
local use_standard_markers=true
local had_config_flag=false

IFS=";" read -r -a configs <<< "$hook_config"

Expand Down Expand Up @@ -142,10 +143,11 @@ function terraform_docs {
local tf_docs_formatter="md"

else

had_config_flag=true
local config_file=${args#*--config}
config_file=${config_file#*=}
config_file=${config_file% *}
config_file=${config_file% --*}
args=${args/--config=$config_file/}

# Prioritize `.terraform-docs.yml` `output.file` over
# `--hook-config=--path-to-file=` if it set
Expand Down Expand Up @@ -231,8 +233,13 @@ function terraform_docs {
have_marker=$(grep -o "$insertion_marker_begin" "$output_file") || unset have_marker
[[ ! $have_marker ]] && popd > /dev/null && continue
fi
if [[ $had_config_flag == true ]]; then
# shellcheck disable=SC2086
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter --config="$config_file" $args ./ > /dev/null
else
# shellcheck disable=SC2086
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter $args ./ > /dev/null
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter $config_arg $args ./ > /dev/null
fi

popd > /dev/null
done
Expand Down
Loading