Commit Graph

111 Commits

Author SHA1 Message Date
Niklas Ye a30c52f6dd Fix: move var declaration after imports
Release / build (amd64, darwin) (push) Failing after 1m8s
Release / build (arm64, darwin) (push) Failing after 1m5s
Release / build (amd64, linux) (push) Failing after 1m8s
Release / build (arm64, linux) (push) Failing after 21s
Release / release (push) Has been skipped
Release / chart (push) Failing after 1m27s
Release / docker (push) Failing after 3m4s
terdut-server-0.1.0 v0.1.0
2026-05-21 17:17:23 +02:00
Niklas Ye 6baaf96638 Add release workflow, LICENSE, and version stamping
Tag-triggered workflow builds multi-platform binaries, pushes a multi-arch
Docker image to GHCR, bumps and releases the Helm chart, and creates a
GitHub release with all binary artifacts. Adds GPL-3.0 LICENSE and version
variable stamped at build time via ldflags.
2026-05-21 17:08:29 +02:00
Niklas Ye 591290e4ee Add Helm chart and chart-release workflow
charts/terdut-server/ — Helm chart for Kubernetes deployment:
  - Deployment (replicas=1, /healthz probes, TERDUT_DB_PATH=/data/terdut.db)
  - Service (ClusterIP :8080)
  - PVC (1Gi, synology-iscsi) mounted at /data
  - HTTPRoute via envoy-main gateway

.github/workflows/chart-release.yml — packages and publishes the chart to
gh-pages branch on any push to main that touches charts/; repo URL will be
https://yeniklas.github.io/terdut-server once the repo is made public
2026-05-21 15:26:11 +02:00
Niklas Ye 17f09558cb Stage 7: Dockerfile, integration tests, updated README
Dockerfile:
- Multi-stage build (golang:1.25-alpine → scratch)
- CGO_ENABLED=0, static binary, stripped with -ldflags="-w -s" (~11 MB)

Tests (13 cases, internal/api/api_test.go):
- Auth middleware: missing token, invalid token, valid token
- Bootstrap idempotency (second call → 403)
- Alert upsert: same fingerprint updates row; different fingerprints add rows
- Acknowledge: set and clear, verified via GET
- Comment ownership: only author can delete own comment (404 for others)
- Schedule conflict: duplicate date → 409; multi-date rollback on partial conflict
- Stats: totals, by-hour returns 24 slots, by-day returns 7 slots

README: quick start, Docker, env vars, Alertmanager config, full API reference
2026-05-20 22:35:26 +02:00
Niklas Ye 923fc8bf9c Stage 6: alert statistics endpoints
- GET /api/stats/alerts       — total/firing/resolved counts
- GET /api/stats/alerts/top   — most frequent alert names (?limit, default 10)
- GET /api/stats/alerts/by-hour — counts for all 24 hours (zeros filled in)
- GET /api/stats/alerts/by-day  — counts for all 7 days with names (zeros filled in)
- All endpoints accept optional ?from/?to (YYYY-MM-DD) to filter by received_at
2026-05-20 22:31:18 +02:00
Niklas Ye f8f209dcba Stage 5: on-call schedule
- Migration 005: schedule_entries table (date TEXT UNIQUE, one person per day)
- POST /api/schedule — assign user to one or more dates in a single
  transaction; any date conflict rejects the whole request (409)
- GET /api/schedule — list all entries ordered by date, optional ?from/?to
- GET /api/schedule/current — today's on-call user (UTC date), 404 if none
- DELETE /api/schedule/{id} — remove an entry (204)
2026-05-20 22:28:23 +02:00
Niklas Ye c3348a410a Stage 4: alert acknowledgement and comments
- Migration 004: acknowledged_by/acknowledged_at columns on alerts,
  alert_comments table (FK cascade on delete)
- POST /api/alerts/{id}/acknowledge — stamps authed user + timestamp,
  returns updated alert with acknowledged_by username
- DELETE /api/alerts/{id}/acknowledge — clears ack (204)
- GET /api/alerts/{id}/comments — list in chronological order
- POST /api/alerts/{id}/comments — add comment (returns 201)
- DELETE /api/alerts/{id}/comments/{commentID} — own comments only (204)
- All alert queries now LEFT JOIN users for ack username
2026-05-20 21:57:11 +02:00
Niklas Ye 9b4ca1482f Stage 3: Alertmanager webhook ingestion and alert query API
- Migration 003: alerts table with fingerprint UNIQUE, JSON label/annotation
  columns, nullable ends_at, and indexed status/name/received_at
- POST /api/alertmanager/webhook — upserts each alert by fingerprint;
  zero endsAt ("0001-01-01") stored as NULL (still firing)
- GET /api/alerts — filtered list (?status, ?name, ?from, ?to, ?limit)
- GET /api/alerts/{id} — single alert lookup
2026-05-20 21:54:17 +02:00
Niklas Ye 7c3c28b23c Stage 2: users, API key auth, bootstrap endpoint
- Migration 002: users and api_keys tables (Unix timestamps, FK cascade)
- POST /api/bootstrap — creates first user + key when DB is empty
- POST/GET/DELETE /api/users — user CRUD
- POST/DELETE /api/users/{id}/api-keys — key issuance and revocation
- AuthMiddleware: SHA-256 bearer token lookup, last_used_at tracking
- Raw key returned once on creation; only SHA-256 hash stored
2026-05-20 21:51:09 +02:00
Niklas Ye 0387e1e017 Stage 1: project skeleton, SQLite, migrations, HTTP server
- go mod init with chi, modernc.org/sqlite, golang.org/x/crypto
- Custom embedded migration runner (no CGO dependency)
- Config from TERDUT_ADDR / TERDUT_DB_PATH env vars
- chi router with /healthz endpoint
- Graceful shutdown on SIGINT/SIGTERM
2026-05-20 21:41:40 +02:00
Niklas Ye 5f458868b0 Initial commit: add README with project spec
Terminal Duty (terdut-server) — on-call management server spec.
2026-05-20 21:38:02 +02:00