mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
chore: Document functions (based on google style guide) (#317)
This commit is contained in:
parent
661a0cf346
commit
321fb16693
11 changed files with 190 additions and 8 deletions
|
|
@ -15,6 +15,19 @@ function main {
|
|||
terraform_validate_
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Parse args and filenames passed to script and populate respective
|
||||
# global variables with appropriate values
|
||||
# Globals (init and populate):
|
||||
# ARGS (array) arguments that configure wrapped tool behavior
|
||||
# INIT_ARGS (array) arguments to `terraform init` command
|
||||
# ENVS (array) environment variables that will be used with
|
||||
# `terraform` commands
|
||||
# FILES (array) filenames to check
|
||||
# Arguments:
|
||||
# $@ (array) all specified in `hooks.[].args` in
|
||||
# `.pre-commit-config.yaml` and filenames.
|
||||
#######################################################################
|
||||
function parse_cmdline_ {
|
||||
declare argv
|
||||
argv=$(getopt -o e:i:a: --long envs:,init-args:,args: -- "$@") || return
|
||||
|
|
@ -46,6 +59,24 @@ function parse_cmdline_ {
|
|||
done
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Wrapper around `terraform validate` tool that checks if code is valid
|
||||
# 1. Export provided env var K/V pairs to environment
|
||||
# 2. Because hook runs on whole dir, reduce file paths to uniq dir paths
|
||||
# 3. In each dir that have *.tf files:
|
||||
# 3.1. Check if `.terraform` dir exists and if not - run `terraform init`
|
||||
# 3.2. Run `terraform validate`
|
||||
# 3.3. If at least 1 check failed - change exit code to non-zero
|
||||
# 4. Complete hook execution and return exit code
|
||||
# Globals:
|
||||
# ARGS (array) arguments that configure wrapped tool behavior
|
||||
# INIT_ARGS (array) arguments for `terraform init` command`
|
||||
# ENVS (array) environment variables that will be used with
|
||||
# `terraform` commands
|
||||
# FILES (array) filenames to check
|
||||
# Outputs:
|
||||
# If failed - print out hook checks status
|
||||
#######################################################################
|
||||
function terraform_validate_ {
|
||||
|
||||
# Setup environment variables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue