Documentation
¶
Overview ¶
Package handler contains the HTTP handlers for the github-build watcher. /trigger publishes a TriggerBuildCheckCommand to Kafka and returns 202; the heavy lifting (Poll cycle) happens in the in-pod command consumer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AvailableWebhookHeaders = []WebhookHeader{WebhookSignatureHeader, WebhookEventHeader}
AvailableWebhookHeaders lists the webhook header names the handler reads.
Functions ¶
This section is empty.
Types ¶
type TriggerBuildCheckHandler ¶
TriggerBuildCheckHandler handles POST /trigger. The handler is intentionally minimal: parse the optional ?force=<bool> query parameter via libparse.ParseBoolDefault (spec 069), build a TriggerBuildCheckCommand carrying the parsed Force value, publish it to Kafka via the injected sender, and return HTTP 202. The Scope field stays reserved-unread (spec Non-goal: per-repo filter UX is a separate spec). All scan-cycle work is owned by the in-pod command consumer.
func NewTriggerBuildCheckHandler ¶
func NewTriggerBuildCheckHandler( sender command.TriggerBuildCheckCommandSender, ) TriggerBuildCheckHandler
NewTriggerBuildCheckHandler returns a handler that publishes a TriggerBuildCheckCommand to Kafka for each /trigger request and returns 202. The sender is the only collaborator.
type WebhookHandler ¶ added in v0.4.0
WebhookHandler handles POST /webhook/github-build. The handler is intentionally thin, mirroring TriggerBuildCheckHandler: verify the GitHub HMAC signature, extract the repo from the workflow_run event, publish a TriggerBuildCheckCommand to Kafka, and return 202. All GitHub API access, filter evaluation, and state-machine logic stays in the in-pod command consumer (shared with /trigger), so the allowlist gate and the green/red state transitions apply to webhook deliveries unchanged.
func NewWebhookHandler ¶ added in v0.4.0
func NewWebhookHandler( sender command.TriggerBuildCheckCommandSender, secret string, metrics WebhookMetrics, clock libtime.CurrentDateTimeGetter, debouncer pkg.Debouncer, ) WebhookHandler
NewWebhookHandler returns a handler that publishes a TriggerBuildCheckCommand for each signature-verified workflow_run webhook delivery that (a) completed with conclusion=failure, (b) ran on the repository's default branch, and (c) passes the per-repo debounce. All other deliveries are acked and skipped.
type WebhookHeader ¶ added in v0.4.0
type WebhookHeader string
WebhookHeader is a typed GitHub webhook header name, so header-name typos are caught by the type system.
const ( WebhookSignatureHeader WebhookHeader = "X-Hub-Signature-256" WebhookEventHeader WebhookHeader = "X-GitHub-Event" )
type WebhookMetrics ¶ added in v0.4.0
type WebhookMetrics interface {
IncWebhookDelivery(result string)
IncWebhookSignatureRejected()
ObserveWebhookDispatchLatency(seconds float64)
// IncWebhookSkipped counts workflow_run deliveries that did not dispatch a
// build-check. reason: "not_completed" | "not_failure" | "not_default_branch" | "debounced".
IncWebhookSkipped(reason string)
}
WebhookMetrics is the narrow slice of watcher metrics the webhook handler records. pkg.Metrics satisfies it structurally, keeping this handler free of the pkg import — mirroring trigger_handler's thin dependency set.