[Event-Bus P2] Source adapters — Forgejo, ArgoCD, Gotify webhooks #22

Open
opened 2026-09-09 23:41:35 +00:00 by poimen · 0 comments
Member

What

Translate raw webhook payloads from each event source into the canonical Event schema.

Why

Each source (Forgejo, ArgoCD, Gotify) has its own webhook format. Adapters normalize them so the router works with a single schema.

Endpoints

  • POST /v1/events/forgejo — raw Forgejo webhook → Event
  • POST /v1/events/argocd — raw ArgoCD webhook → Event
  • POST /v1/events/gotify — Gotify message → Event

Event Type Mapping

Source Webhook Action Event Type
Forgejo PR opened pr.created
Forgejo PR merged pr.merged
Forgejo PR closed pr.closed
Forgejo push push
Forgejo CI success build.success
Forgejo CI failure build.failure
ArgoCD sync succeeded sync.success
ArgoCD sync failed sync.failed
ArgoCD health degraded health.degraded

Depends On

  • #21 Core event router

Acceptance

Forgejo Adapter

  • POST /v1/events/forgejo with PR opened payload → Event {source:"forgejo", type:"pr.created", subject:"owner/repo#N"}
  • POST /v1/events/forgejo with PR merged payload → Event {source:"forgejo", type:"pr.merged"}
  • Event data contains: title, author, branch, url, repo
  • POST /v1/events/forgejo with valid HMAC signature header → 202
  • POST /v1/events/forgejo with invalid HMAC → 403 Forbidden
  • POST /v1/events/forgejo with missing signature header → 403 Forbidden
  • Unknown Forgejo action (e.g., label_updated) → mapped to forgejo.unknown or dropped with 204

ArgoCD Adapter

  • Sync success payload → Event {source:"argocd", type:"sync.success", subject:"app-name"}
  • Health degraded payload → Event {source:"argocd", type:"health.degraded", priority:10}
  • ArgoCD webhook secret validated

Tests

  • go test ./internal/events/adapters/ — Forgejo: test with captured real webhook JSON (PR open, merge, push, CI)
  • go test ./internal/events/adapters/ — ArgoCD: test with captured real webhook JSON (sync success, sync fail, health degraded)
  • go test ./internal/events/adapters/ — HMAC: valid signature passes, tampered body rejects, missing header rejects
  • Negative: malformed JSON body returns 400, not 500
## What Translate raw webhook payloads from each event source into the canonical Event schema. ## Why Each source (Forgejo, ArgoCD, Gotify) has its own webhook format. Adapters normalize them so the router works with a single schema. ## Endpoints - `POST /v1/events/forgejo` — raw Forgejo webhook → Event - `POST /v1/events/argocd` — raw ArgoCD webhook → Event - `POST /v1/events/gotify` — Gotify message → Event ## Event Type Mapping | Source | Webhook Action | Event Type | |--------|---------------|------------| | Forgejo | PR opened | `pr.created` | | Forgejo | PR merged | `pr.merged` | | Forgejo | PR closed | `pr.closed` | | Forgejo | push | `push` | | Forgejo | CI success | `build.success` | | Forgejo | CI failure | `build.failure` | | ArgoCD | sync succeeded | `sync.success` | | ArgoCD | sync failed | `sync.failed` | | ArgoCD | health degraded | `health.degraded` | ## Depends On - #21 Core event router ## Acceptance ### Forgejo Adapter - [ ] `POST /v1/events/forgejo` with PR opened payload → Event `{source:"forgejo", type:"pr.created", subject:"owner/repo#N"}` - [ ] `POST /v1/events/forgejo` with PR merged payload → Event `{source:"forgejo", type:"pr.merged"}` - [ ] Event `data` contains: `title`, `author`, `branch`, `url`, `repo` - [ ] `POST /v1/events/forgejo` with valid HMAC signature header → 202 - [ ] `POST /v1/events/forgejo` with invalid HMAC → `403 Forbidden` - [ ] `POST /v1/events/forgejo` with missing signature header → `403 Forbidden` - [ ] Unknown Forgejo action (e.g., `label_updated`) → mapped to `forgejo.unknown` or dropped with 204 ### ArgoCD Adapter - [ ] Sync success payload → Event `{source:"argocd", type:"sync.success", subject:"app-name"}` - [ ] Health degraded payload → Event `{source:"argocd", type:"health.degraded", priority:10}` - [ ] ArgoCD webhook secret validated ### Tests - [ ] `go test ./internal/events/adapters/` — Forgejo: test with captured real webhook JSON (PR open, merge, push, CI) - [ ] `go test ./internal/events/adapters/` — ArgoCD: test with captured real webhook JSON (sync success, sync fail, health degraded) - [ ] `go test ./internal/events/adapters/` — HMAC: valid signature passes, tampered body rejects, missing header rejects - [ ] Negative: malformed JSON body returns 400, not 500
poimen added this to the Event-Driven Platform milestone 2026-09-09 23:41:35 +00:00
poimen added the area/event-busstatus/todoarea/gatewaytype/featurepriority/medium labels 2026-09-09 23:41:36 +00:00
Sign in to join this conversation.