Files
test-e2e/scripts/orchestra_e2e_healthcheck.sh
T

47 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
readonly VERSION=1.0.0
# 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() {
local quiet=
local json=
for arg in "$@"; do
if [ "$arg" = --help ]; then
emit text 'Usage: %s [--quiet]\n\n' "${0##*/}"
emit text 'Healthcheck script for Orchestra E2E tests.\n'
emit text 'Exits 0 with a success message if all checks pass.\n'
emit text ' --quiet Suppress the success message; still exits 0.\n'
emit text ' Off by default; the success message prints unless --quiet is given.\n'
emit text 'Version: %s\n' "$VERSION"
exit 0
elif [ "$arg" = --quiet ]; then
quiet=1
elif [ "$arg" = --json ]; then
json=1
fi
done
local format=text
[ -n "$quiet" ] && format=none
[ -n "$json" ] && format=json
if [ "$format" = json ]; then
emit "$format" '{"status":"ok","checks":1}\n'
exit 0
fi
emit "$format" 'OK - all healthchecks passed\n'
exit 0
}
main "$@"