forked from brendanhay/amazonka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-configs
More file actions
executable file
·67 lines (53 loc) · 1.56 KB
/
Copy pathgenerate-configs
File metadata and controls
executable file
·67 lines (53 loc) · 1.56 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../shell.nix
# Usage: generate-configs OUTPUT
#
# Generates configuration for all services found in BOTOCORE_PATH that
# are missing corresponding configurations in ./config/services.
#
# The example configurations will be written to individual files under
# OUTPUT/configs and OUTPUT/annexes.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
botocore="${BOTOCORE_PATH?}"
services="config/services"
output="${1?An OUTPUT argument is required}"
configs="$output/configs"
annexes="$output/annexes"
available=()
configured=()
unconfigured=0
# Output a message to stderr.
say() {
echo >&2 "$@"
}
# Write an example configuration and annex to name.json.
write_config() {
local -r name="$1"
local -r config="$configs/$name.json"
local -r annex="$annexes/$name.json"
say "Missing $name"
jq -n --arg name "$name" '{ libraryName: $name }' >"$config"
jq -n --arg name "$name" '{}' >"$annex"
}
for path in "${botocore}"/*/; do
model="${path%/}"
model="${model##*/}"
available+=("$model")
done
for path in "${services}"/*.json; do
model="${path##*/}"
model="${model%%.*}"
configured+=("$model")
done
mkdir -p "$configs" "$annexes"
for name in $(comm -13 <(printf "%s\n" "${configured[@]}" | sort) <(printf "%s\n" "${available[@]}" | sort)); do
unconfigured=$((unconfigured + 1))
write_config "$name"
done
say "\
Missing $unconfigured service configurations.
Wrote examples to $configs and $annexes.
Found ${#available[@]} models in $botocore.
Found ${#configured[@]} service configurations in $services.
Done."