Skip to content

Commit 75c79fe

Browse files
committed
Add files remove typo
1 parent 989eaa3 commit 75c79fe

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

services/monitoring/grafana/terraform/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
main.tf
2-
.terraform/** */
2+
.terraform/**
33
.terraform.lock.hcl
44
plan.cache
55
terraform.tfstate
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
DIRECTORY=$1
5+
6+
# Find all JSON files within the directory
7+
FILES=$(find "$DIRECTORY" -mindepth 1 -maxdepth 1 -type f -name '*.json')
8+
9+
# Create a JSON object where each file's basename is the key, with full paths as values
10+
JSON_OBJECT=$(echo "$FILES" | while read -r FILE; do
11+
BASENAME=$(basename "$FILE" .json)
12+
echo "{\"$BASENAME\": \"$FILE\"}"
13+
done | jq -s 'add')
14+
15+
# Output the JSON map
16+
jq -n --argjson files "$JSON_OBJECT" '$files'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
DIRECTORY=$1
5+
6+
# Use `find` to get the directories' base names
7+
SUBFOLDERS=$(find "$DIRECTORY" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
8+
9+
# Convert the subfolder names into a JSON object with jq, where each is paired with itself
10+
JSON_OBJECT=$(echo "$SUBFOLDERS" | tr ' ' '\n' | jq -Rn '
11+
[inputs] |
12+
map(select(. != "")) |
13+
map({key: ., value: .}) |
14+
from_entries')
15+
# Output the JSON map
16+
jq -n --argjson subfolders "$JSON_OBJECT" '$subfolders'

0 commit comments

Comments
 (0)