orchestra: pre-release WIP snapshot (orchestra-06g4gwwj8swfref06hdyebag0c-940ab9dd)
This commit is contained in:
@@ -1,14 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# emit <format> <template> [args...]: the single output path.
|
||||||
|
# format: text or json print; none suppresses (--quiet). Explicit argument,
|
||||||
|
# never read from an enclosing variable.
|
||||||
|
emit() {
|
||||||
|
local format=$1
|
||||||
|
shift
|
||||||
|
[ "$format" = none ] || printf "$@"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local quiet=
|
local quiet=
|
||||||
local json=
|
local json=
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ "$arg" = --help ]; then
|
if [ "$arg" = --help ]; then
|
||||||
printf 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
emit text 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
||||||
printf 'Healthcheck script for Orchestra E2E tests.\n'
|
emit text 'Healthcheck script for Orchestra E2E tests.\n'
|
||||||
printf 'Exits 0 with a success message if all checks pass.\n'
|
emit text 'Exits 0 with a success message if all checks pass.\n'
|
||||||
printf ' --quiet Suppress the success message; still exits 0.\n'
|
emit text ' --quiet Suppress the success message; still exits 0.\n'
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$arg" = --quiet ]; then
|
elif [ "$arg" = --quiet ]; then
|
||||||
quiet=1
|
quiet=1
|
||||||
@@ -17,12 +26,16 @@ main() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$json" ]; then
|
local format=text
|
||||||
printf '{"status":"ok","checks":1}\n'
|
[ -n "$quiet" ] && format=none
|
||||||
|
[ -n "$json" ] && format=json
|
||||||
|
|
||||||
|
if [ "$format" = json ]; then
|
||||||
|
emit "$format" '{"status":"ok","checks":1}\n'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$quiet" ] || printf 'OK - all healthchecks passed\n'
|
emit "$format" 'OK - all healthchecks passed\n'
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user