Cottage catalog: three starter recipes
Vaultwarden, Actual Budget and Uptime Kuma, each a Harbor template with a listing, an icon, first-run notes and a smoke test. CI builds Harbor at the pinned commit and runs every recipe's smoke test against its fake runtime.
This commit is contained in:
commit
a0d992022d
21 files changed
+549
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Smoke test one recipe against a harbord: upload → deploy → wait for running →
|
||||
# HTTP check of health_path through the node's router (real runtime only) → delete.
|
||||
#
|
||||
# HARBOR_URL=http://127.0.0.1:7700 HARBOR_TOKEN=hbr_... scripts/smoke.sh apps/vaultwarden
|
||||
#
|
||||
# HEALTH_BASE (optional) is how this machine reaches pod hostnames, e.g. https://%s
|
||||
# where %s is replaced with the pod's domain. Without it the HTTP check is skipped,
|
||||
# which is what the fake runtime needs.
|
||||
set -eu
|
||||
dir=$(cd "${1:?recipe directory}" && pwd)
|
||||
: "${HARBOR_URL:?}" "${HARBOR_TOKEN:?}"
|
||||
api() { curl -fsS -H "Authorization: Bearer $HARBOR_TOKEN" "$@"; }
|
||||
json() { python3 -c "import sys,json; d=json.load(sys.stdin); print($1)"; }
|
||||
|
||||
slug=$(basename "$dir")
|
||||
api -X POST -H 'Content-Type: application/yaml' --data-binary @"$dir/template.yml" "$HARBOR_URL/v1/templates" >/dev/null
|
||||
version=$(api "$HARBOR_URL/v1/templates?slug=$slug" | json "sorted(d['data'], key=lambda t: t['created_at'])[-1]['version']")
|
||||
health=$(api "$HARBOR_URL/v1/templates/$slug?version=$version" | json "d.get('health_path','/')")
|
||||
ref="smoke-$slug-$$"
|
||||
pod=$(api -X POST -H "Idempotency-Key: $ref" -d "{\"slug\":\"smoke-$$\",\"external_ref\":\"$ref\",\"template\":\"$slug\",\"template_version\":\"$version\"}" \
|
||||
"$HARBOR_URL/v1/pods" | json "d['pod']['id']")
|
||||
trap 'api -X DELETE "$HARBOR_URL/v1/pods/$pod?purge=true" >/dev/null || true' EXIT
|
||||
|
||||
for _ in $(seq 1 60); do
|
||||
status=$(api "$HARBOR_URL/v1/pods/$pod" | json "d['status']")
|
||||
[ "$status" = running ] && break
|
||||
[ "$status" = failed ] && { echo "$slug: pod failed"; exit 1; }
|
||||
sleep 2
|
||||
done
|
||||
[ "$status" = running ] || { echo "$slug: not running after 120 s (status $status)"; exit 1; }
|
||||
|
||||
if [ -n "${HEALTH_BASE:-}" ]; then
|
||||
domain=$(api "$HARBOR_URL/v1/pods/$pod" | json "d['domain']")
|
||||
# shellcheck disable=SC2059
|
||||
url="$(printf "$HEALTH_BASE" "$domain")$health"
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 120 --retry 20 --retry-delay 3 --retry-all-errors "$url")
|
||||
[ "$code" = 200 ] || { echo "$slug: $url returned $code"; exit 1; }
|
||||
fi
|
||||
echo "$slug@$version: ok"
|
||||
Reference in new issue
Block a user