Documentation
¶
Overview ¶
Package webhookctrl implements the webhook-controller engine: the router between the GitHub App's single webhook URL and the controllers' cluster-internal receivers. A GitHub App can deliver to exactly one URL, but every controller runs its own receiver, so the webhook-controller — the only internet-facing patchy component — accepts each delivery once and forwards it to the targets its X-GitHub-Event type routes to (a "*" route catches event types no rule claims, e.g. those registered by pkg/source plugins).
The webhook-controller holds no GitHub credential. It shares only the webhook HMAC secret, which it uses twice: internal/webhook validates the inbound signature before anything is forwarded, and the Forwarder re-signs the payload on the way out (an identical signature, since the secret is the same), so every controller keeps authenticating every delivery itself. Forwarding is best-effort: a failed or unrouted target is logged and skipped, because the controllers' reconcile loops — not webhook redelivery — are the correctness mechanism.
Index ¶
Constants ¶
const DefaultRoute = "*"
DefaultRoute is the Routes key that catches event types with no route of their own.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Secret is the shared webhook HMAC secret. The forwarded
// X-Hub-Signature-256 is recomputed from it — byte-identical to the one
// GitHub sent — so the controllers keep validating every delivery.
Secret []byte
// Routes maps an X-GitHub-Event type to the webhook endpoints that
// consume it, e.g. "code_scanning_alert" ->
// http://patchy-source-controller:8080/webhook. The DefaultRoute ("*")
// entry, when present, receives every event type no other key claims.
Routes map[string][]string
// Timeout bounds each per-target forward. Default 10s.
Timeout time.Duration
// Client optionally overrides the HTTP client (tests). Timeouts are
// applied per request via context, not on the client.
Client *http.Client
}
Config configures a Forwarder.
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder routes one validated delivery to the targets that consume its event type. It implements webhook.Handler, so it plugs straight into webhook.NewServer.
func New ¶
New builds a Forwarder; defaults are applied here so the zero Config fields need no ceremony at call sites.
func (*Forwarder) Handle ¶
Handle forwards the delivery to its event type's targets concurrently and reports the targets that failed. A partial failure still delivers to the healthy targets; the failed controller's reconcile loop is the retry mechanism. An event type with no route (and no DefaultRoute) is dropped without error — GitHub only sends subscribed events, so this is a routing config gap, not a delivery failure worth retrying.