forked from hystax/optscale
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_modules_json.sh
More file actions
executable file
·41 lines (33 loc) · 1.07 KB
/
generate_modules_json.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euo pipefail
# List of components to exclude
EXCLUDE_LIST=(
"etcd" "mongo" "mariadb" "redis" "filebeat" "grafana"
"grafana_nginx" "elk" "cleanelkdb" "jira_bus" "jira_ui"
"slacker" "subsyncer" "bailiff" "subspector"
)
# Function to check if component is in the exclusion list
should_exclude() {
local component="$1"
for excluded in "${EXCLUDE_LIST[@]}"; do
if [[ "$component" == "$excluded" ]]; then
return 0
fi
done
return 1
}
# Initialize an array to store JSON objects
entries=()
# Find Dockerfiles
while IFS= read -r -d '' dockerfile; do
component=$(basename "$(dirname "$dockerfile")")
if should_exclude "$component"; then
continue
fi
# Escape values for JSON
entries+=("{\"name\": \"${component}\", \"dockerfile\": \"${dockerfile}\"}")
done < <(find . -mindepth 2 -maxdepth 3 -type f -name 'Dockerfile' ! -name '*test*' ! -name '*.j2' -print0)
# Join entries with comma
joined=$(IFS=, ; echo "${entries[*]}")
# Output final JSON
echo -n "{\"include\": [${joined}]}"