MCPcopy Create free account
hub / github.com/cloudbase/garm / WebhookHandler

Method WebhookHandler

apiserver/controllers/controllers.go:184–210  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

182}
183
184func (a *APIController) WebhookHandler(w http.ResponseWriter, r *http.Request) {
185 ctx := r.Context()
186
187 vars := mux.Vars(r)
188 controllerID, ok := vars["controllerID"]
189 // If the webhook URL includes a controller ID, we validate that it's meant for us. We still
190 // support bare webhook URLs, which are tipically configured manually by the user.
191 // The controllerID suffixed webhook URL is useful when configuring the webhook for an entity
192 // via garm. We cannot tag a webhook URL on github, so there is no way to determine ownership.
193 // Using a controllerID suffix is a simple way to denote ownership.
194 if ok && controllerID != a.controllerID {
195 slog.InfoContext(ctx, "ignoring webhook meant for foreign controller", "req_controller_id", controllerID)
196 return
197 }
198
199 headers := r.Header.Clone()
200
201 event := runnerParams.Event(headers.Get("X-Github-Event"))
202 switch event {
203 case runnerParams.WorkflowJobEvent:
204 a.handleWorkflowJobEvent(ctx, w, r)
205 case runnerParams.PingEvent:
206 // Ignore ping event. We may want to save the ping in the github entity table in the future.
207 default:
208 slog.DebugContext(ctx, "ignoring unknown event", "gh_event", util.SanitizeLogEntry(string(event)))
209 }
210}
211
212func (a *APIController) EventsHandler(w http.ResponseWriter, r *http.Request) {
213 ctx := r.Context()

Callers

nothing calls this directly

Calls 2

GetMethod · 0.45

Tested by

no test coverage detected