Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
16 lines
758 B
Bash
Executable File
16 lines
758 B
Bash
Executable File
#!/bin/sh
|
|
# Creates every topic and subscription in topics.txt on the Pub/Sub emulator. Idempotent.
|
|
set -eu
|
|
base="http://pubsub:8085/v1/projects/co-lite-local"
|
|
grep -v '^#' /pubsub/topics.txt | while read -r topic sub; do
|
|
[ -z "$topic" ] && continue
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' -X PUT "$base/topics/$topic")
|
|
case $code in 200|409) ;; *) echo "topic $topic failed: HTTP $code"; exit 1;; esac
|
|
if [ -n "${sub:-}" ]; then
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H 'Content-Type: application/json' \
|
|
-d "{\"topic\":\"projects/co-lite-local/topics/$topic\"}" "$base/subscriptions/$sub")
|
|
case $code in 200|409) ;; *) echo "subscription $sub failed: HTTP $code"; exit 1;; esac
|
|
fi
|
|
done
|
|
echo "pubsub-init: done"
|