-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
989eaa3
commit 75c79fe
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main.tf | ||
.terraform/** */ | ||
.terraform/** | ||
.terraform.lock.hcl | ||
plan.cache | ||
terraform.tfstate | ||
|
16 changes: 16 additions & 0 deletions
16
services/monitoring/grafana/terraform/tf_helper_list_json_files_in_folder.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
DIRECTORY=$1 | ||
|
||
# Find all JSON files within the directory | ||
FILES=$(find "$DIRECTORY" -mindepth 1 -maxdepth 1 -type f -name '*.json') | ||
|
||
# Create a JSON object where each file's basename is the key, with full paths as values | ||
JSON_OBJECT=$(echo "$FILES" | while read -r FILE; do | ||
BASENAME=$(basename "$FILE" .json) | ||
echo "{\"$BASENAME\": \"$FILE\"}" | ||
done | jq -s 'add') | ||
|
||
# Output the JSON map | ||
jq -n --argjson files "$JSON_OBJECT" '$files' |
16 changes: 16 additions & 0 deletions
16
services/monitoring/grafana/terraform/tf_helper_list_subfolders.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
DIRECTORY=$1 | ||
|
||
# Use `find` to get the directories' base names | ||
SUBFOLDERS=$(find "$DIRECTORY" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) | ||
|
||
# Convert the subfolder names into a JSON object with jq, where each is paired with itself | ||
JSON_OBJECT=$(echo "$SUBFOLDERS" | tr ' ' '\n' | jq -Rn ' | ||
[inputs] | | ||
map(select(. != "")) | | ||
map({key: ., value: .}) | | ||
from_entries') | ||
# Output the JSON map | ||
jq -n --argjson subfolders "$JSON_OBJECT" '$subfolders' |