-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathulticode
More file actions
executable file
·61 lines (56 loc) · 1.55 KB
/
Copy pathulticode
File metadata and controls
executable file
·61 lines (56 loc) · 1.55 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat <<'EOF'
Usage:
./ulticode dev [up.sh options]
./ulticode host --config <ulticode.yml>
./ulticode doctor [doctor.sh options]
The host config accepts only the thin resolver keys `scope` and
`observability`; service startup remains owned by scripts/dev/up.sh.
EOF
}
read_host_config() {
local config="$1" key value
[[ -r "$config" ]] || { echo "host config is not readable: $config" >&2; exit 2; }
HOST_SCOPE="dev-lite"
HOST_OBSERVABILITY=false
while IFS=':' read -r key value; do
key="${key#"${key%%[![:space:]]*}"}"
key="${key%"${key##*[![:space:]]}"}"
value="${value#"${value%%[![:space:]]*}"}"
value="${value%"${value##*[![:space:]]}"}"
[[ -z "$key" || "$key" == \#* ]] && continue
case "$key" in
scope) HOST_SCOPE="$value" ;;
observability) [[ "$value" == true ]] && HOST_OBSERVABILITY=true ;;
*) echo "unsupported host config key: $key" >&2; exit 2 ;;
esac
done < "$config"
}
case "${1:-}" in
dev)
shift
exec "$ROOT_DIR/scripts/dev/up.sh" --mode dev-lite "$@"
;;
host)
[[ "${2:-}" == "--config" && -n "${3:-}" ]] || { usage >&2; exit 2; }
read_host_config "$3"
shift 3
args=(--scope "$HOST_SCOPE")
[[ "$HOST_OBSERVABILITY" == true ]] && args+=(--observability)
exec "$ROOT_DIR/scripts/dev/up.sh" "${args[@]}" "$@"
;;
doctor)
shift
exec "$ROOT_DIR/scripts/dev/doctor.sh" "$@"
;;
-h|--help)
usage
;;
*)
usage >&2
exit 2
;;
esac