v0: stdlib-only Discourse client — categories/topics/posts + raw passthrough
Covers the MOPAC briefing/report surface (Redmine 495 Part A): category
list/create (create needs the admin-scoped key; current key 403s, typed
as ErrForbidden), topic create/list/latest/get, post create/update/get,
current-user identity probe, and a Do() JSON passthrough so unmodeled
endpoints need no client release. Key is env/constructor-only, never a
flag, never logged; errors classify via errors.Is. Fake-server unit
tests + containerized end-to-end smoke (redaction sweep included); live
reads verified against community.turnsys.com.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# mopac-discourse-go dev wrapper. EVERY compile/vet/test path routes
|
||||
# through the digest-pinned Docker builder (MOPAC big rule: ALL dev work
|
||||
# in Docker — the host runs containers, never toolchains).
|
||||
#
|
||||
# Usage: ./dev.sh {build|vet|test|check|smoke|shell} [args...]
|
||||
#
|
||||
# build compile ./cmd/discourse-go into bin/
|
||||
# vet go vet ./...
|
||||
# test go test ./...
|
||||
# check build + vet + test (the pre-commit gate)
|
||||
# smoke end-to-end smoke against the in-repo fake Discourse
|
||||
# shell interactive sh inside the builder
|
||||
set -e
|
||||
|
||||
IMAGE="golang@sha256:e8c859f5632dcfde7b32d2012b4351728f6437930887c2f6a91ea242459e5514" # = golang:1.26-bookworm
|
||||
|
||||
run() {
|
||||
docker run --rm -v "$PWD:/h" -w /h \
|
||||
-u "$(id -u):$(id -g)" -e HOME=/tmp -e GOFLAGS=-buildvcs=false \
|
||||
"$IMAGE" "$@"
|
||||
}
|
||||
|
||||
cmd=${1:-check}
|
||||
shift || true
|
||||
|
||||
case "$cmd" in
|
||||
build)
|
||||
run go build -o bin/discourse-go ./cmd/discourse-go
|
||||
;;
|
||||
vet)
|
||||
run go vet ./...
|
||||
;;
|
||||
test)
|
||||
run go test "$@" ./...
|
||||
;;
|
||||
check)
|
||||
run sh -c 'go build -o bin/discourse-go ./cmd/discourse-go && go vet ./... && go test ./...'
|
||||
;;
|
||||
smoke)
|
||||
./smoke/smoke.sh
|
||||
;;
|
||||
shell)
|
||||
run sh
|
||||
;;
|
||||
*)
|
||||
echo "dev.sh: unknown command $cmd (want build|vet|test|check|smoke|shell)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user