bazel: add terraform fmt to //:tidy target (#1501)

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-03-22 13:14:35 -04:00 committed by GitHub
parent 7d899d7aa5
commit b65b09fd9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -195,6 +195,18 @@ sh_template(
template = "tf.sh.in",
)
sh_template(
name = "terraform_fmt",
data = [
":com_github_hashicorp_terraform",
],
substitutions = {
"@@MODE@@": "format",
"@@TERRAFORM@@": "$(rootpath :com_github_hashicorp_terraform)",
},
template = "tf.sh.in",
)
multirun(
name = "tidy",
commands = [
@ -204,6 +216,7 @@ multirun(
":gazelle_update_repos",
":gazelle_generate",
":buildifier_fix",
":terraform_fmt",
],
jobs = 1, # execute sequentially
visibility = ["//visibility:public"],

View File

@ -57,6 +57,14 @@ case ${mode} in
done
;;
"format")
echo "Formatting the following Terraform modules:"
for module in "${terraformModules[@]}"; do
echo " ${module}"
${terraform} -chdir="${module}" fmt -recursive > /dev/null
done
;;
"generate")
echo "Formatting and generating lock files for the following Terraform modules:"
for script in "${terraformModules[@]}"; do
@ -70,7 +78,6 @@ case ${mode} in
${terraform} -chdir="${module}" providers lock -platform=darwin_arm64 > /dev/null
${terraform} -chdir="${module}" providers lock -platform=darwin_amd64 > /dev/null
${terraform} -chdir="${module}" providers lock -platform=windows_amd64 > /dev/null
${terraform} -chdir="${module}" fmt -recursive > /dev/null
rm -rf "${module}/.terraform"
done
;;