Mirror of https://github.com/roostorg/osprey
github.com/roostorg/osprey
1#!/bin/bash
2
3usage() {
4 cat <<EOF
5Usage: entrypoint.sh <command>
6Osprey docker entrypoint.
7
8Commands:
9 osprey-worker
10 Runs the worker
11 osprey-ui-api
12 Runs the Osprey UI API
13 run-tests
14 Runs tests for the various projects supported here
15 operator
16 Waits.
17EOF
18 exit 1
19}
20
21cli-osprey-ui-api() {
22 exec uv run gunicorn \
23 --reload \
24 --access-logfile - \
25 --error-logfile - \
26 --logger-class jslog4kube.GunicornLogger \
27 --name osprey_ui_api \
28 --worker-class gevent \
29 --chdir /osprey/osprey_worker/src \
30 --bind :5004 \
31 "osprey.worker.ui_api.osprey.app:create_app()"
32}
33
34cli-osprey-worker() {
35 exec uv run python3.11 osprey_worker/src/osprey/worker/cli/sinks.py run-rules-sink
36}
37
38cli-run-tests() {
39 # Only use in CI via harbormaster buildkite run_tests VARIANT PROJECT [directories]
40 # Docker command will be run-tests --junitxml=/osprey/junit-pytest.xml [directory]
41 # Last argument is the directory, the rest are pytest args
42 exec uv run python3.11 -m gevent.monkey --module pytest "${@}"
43}
44
45cli-operator() {
46 while true; do
47 sleep 600
48 done
49}
50
51cmd="${1:-}"
52case "${cmd}" in
53"" | "-h" | "--help")
54 usage
55 ;;
56*)
57 if [[ "$(type -t "cli-${cmd}")" = "function" ]]; then
58 shift
59 "cli-${cmd}" "$@"
60 else
61 echo "Unknown command: ${cmd}"
62 echo ""
63 usage
64 fi
65 ;;
66esac