Documentation
¶
Overview ¶
Package webhook is the GitHub-webhook HTTP server the integration-controller embeds: HMAC-SHA256 signature validation on the raw body (against a static secret or the per-Integration candidate set), immediate 202 acknowledgement into a bounded worker pool, delivery-ID deduplication, and health/readiness endpoints with graceful drain.
Handlers must be idempotent — GitHub redelivers, the dedup window is finite, and the controllers' reconcile loops converge missed or dropped deliveries anyway.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Addr is the listen address, e.g. ":8080".
Addr string
// Secret is the shared webhook secret used to validate
// X-Hub-Signature-256.
Secret []byte
// SecretsFor, when set, supersedes Secret: it returns the candidate
// secrets for a delivery (e.g. the webhook secrets of every configured
// Integration) and validation accepts a signature matching any of them.
// Secrets are configuration objects, so the candidate set is tiny.
SecretsFor func(ctx context.Context) [][]byte
// Path is the webhook endpoint path. Default "/webhook".
Path string
// Workers is the handler pool size. Default 4.
Workers int
// QueueSize bounds the delivery queue; a full queue answers 503 so
// GitHub redelivers. Default 64.
QueueSize int
// Ready optionally gates /readyz; nil means ready once serving.
Ready func() bool
}
Config configures a Server.
type Event ¶
type Event struct {
// Type is the X-GitHub-Event header value, e.g. "code_scanning_alert".
Type string
// DeliveryID is the X-GitHub-Delivery GUID.
DeliveryID string
// Payload is the raw JSON body.
Payload []byte
}
Event is one validated webhook delivery.
type Handler ¶
Handler consumes validated deliveries. Handle runs on a worker goroutine; returning an error records the failure but is not retried here — the reconcile loop is the retry mechanism.
type HandlerFunc ¶
HandlerFunc adapts a function to Handler.