|
1 | 1 | #!/bin/bash |
2 | | - |
3 | 2 | set -e |
4 | 3 |
|
5 | 4 | warnings=() |
6 | | -recommended_tf_files=("main.tf" "variables.tf" "outputs.tf" "provider.tf" "versions.tf") |
7 | 5 |
|
8 | | -# Nur Verzeichnisse prüfen, in denen mindestens eine .tf-Datei liegt |
9 | | -for buildingblock_path in $(find . -type f -name "*.tf" -exec dirname {} \; | sort -u); do |
10 | | - for tf_file in "${recommended_tf_files[@]}"; do |
11 | | - if [[ ! -f "$buildingblock_path/$tf_file" ]]; then |
12 | | - warnings+=("⚠️ '$tf_file' fehlt in $buildingblock_path") |
| 6 | +# Required Terraform files |
| 7 | +common_tf_files=("main.tf" "variables.tf" "outputs.tf" "provider.tf" "versions.tf") |
| 8 | +readme_file="APP_TEAM_README.md" |
| 9 | + |
| 10 | +# Find relevant module directories |
| 11 | +mapfile -t paths_to_check < <(find modules/ -type d \( -path "*/buildingblock" -o -path "*/backplane" \)) |
| 12 | + |
| 13 | +if [ "${#paths_to_check[@]}" -eq 0 ]; then |
| 14 | + echo "❌ No Terraform module folders found." |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +# Check each directory silently unless a file is missing |
| 19 | +for path in "${paths_to_check[@]}"; do |
| 20 | + for tf_file in "${common_tf_files[@]}"; do |
| 21 | + if [[ ! -f "$path/$tf_file" ]]; then |
| 22 | + warnings+=("⚠️ '$tf_file' is missing in $path") |
13 | 23 | fi |
14 | 24 | done |
| 25 | + |
| 26 | + if [[ "$(basename "$path")" == "buildingblock" ]]; then |
| 27 | + if [[ ! -f "$path/$readme_file" ]]; then |
| 28 | + warnings+=("⚠️ '$readme_file' is missing in $path") |
| 29 | + fi |
| 30 | + fi |
15 | 31 | done |
16 | 32 |
|
17 | | -# Ausgabe & Exit-Code |
| 33 | +# Output only if something's wrong |
18 | 34 | if [ "${#warnings[@]}" -gt 0 ]; then |
| 35 | + echo "❌ Issues detected:" |
19 | 36 | for warn in "${warnings[@]}"; do |
20 | 37 | echo "$warn" |
21 | 38 | done |
22 | 39 | exit 1 |
23 | 40 | else |
24 | | - echo "✅ Alle empfohlenen Terraform-Dateien sind vorhanden." |
| 41 | + exit 0 |
25 | 42 | fi |
0 commit comments