|
3 | 3 | set -euo pipefail |
4 | 4 |
|
5 | 5 | validate_terraform_directory() { |
6 | | - local dir="$1" |
7 | | - echo "Running \`terraform validate\` in $dir" |
8 | | - pushd "$dir" |
9 | | - terraform init -upgrade |
10 | | - terraform validate |
11 | | - popd |
| 6 | + local dir="$1" |
| 7 | + echo "Running \`terraform validate\` in $dir" |
| 8 | + pushd "$dir" |
| 9 | + terraform init -upgrade |
| 10 | + terraform validate |
| 11 | + popd |
12 | 12 | } |
13 | 13 |
|
14 | 14 | main() { |
15 | | - # Get the directory of the script |
16 | | - local script_dir=$(dirname "$(readlink -f "$0")") |
| 15 | + # Get the directory of the script |
| 16 | + local script_dir=$(dirname "$(readlink -f "$0")") |
17 | 17 |
|
18 | | - # Code assumes that registry directory will always be in same position |
19 | | - # relative to the main script directory |
20 | | - local registry_dir="$script_dir/../registry" |
| 18 | + # Code assumes that registry directory will always be in same position |
| 19 | + # relative to the main script directory |
| 20 | + local registry_dir="$script_dir/../registry" |
21 | 21 |
|
22 | | - # Get all subdirectories in the registry directory. Code assumes that |
23 | | - # Terraform directories won't begin to appear until three levels deep into |
24 | | - # the registry (e.g., registry/coder/modules/coder-login, which will then |
25 | | - # have a main.tf file inside it) |
26 | | - local subdirs=$(find "$registry_dir" -mindepth 3 -type d | sort) |
| 22 | + # Get all subdirectories in the registry directory. Code assumes that |
| 23 | + # Terraform directories won't begin to appear until three levels deep into |
| 24 | + # the registry (e.g., registry/coder/modules/coder-login, which will then |
| 25 | + # have a main.tf file inside it) |
| 26 | + local subdirs=$(find "$registry_dir" -mindepth 3 -type d | sort) |
27 | 27 |
|
28 | | - for dir in $subdirs; do |
29 | | - # Skip over any directories that obviously don't have the necessary |
30 | | - # files |
31 | | - if test -f "$dir/main.tf"; then |
32 | | - validate_terraform_directory "$dir" |
33 | | - fi |
34 | | - done |
| 28 | + for dir in $subdirs; do |
| 29 | + # Skip over any directories that obviously don't have the necessary |
| 30 | + # files |
| 31 | + if test -f "$dir/main.tf"; then |
| 32 | + validate_terraform_directory "$dir" |
| 33 | + fi |
| 34 | + done |
35 | 35 | } |
36 | 36 |
|
37 | 37 | main |
0 commit comments