--- title: "ADR 0043: tkn pac cel provider auto-detection order" --- * Status: accepted * Code: [`pkg/cmd/tknpac/cel/cel.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/cmd/tknpac/cel/cel.go) (`detectProvider`) ## Context `tkn pac cel` takes `--provider` with a default of `auto`. When it is `auto`, `detectProvider` has to name the provider from the headers and body alone. Gitea and Forgejo webhooks are sent with GitHub-compatible headers, so the GitHub header is not enough to tell the three apart. ## Decision Checks run in this order and the first match wins: * `X-GitHub-Event` present: `forgejo` if `X-Forgejo-Event-Type` is also present, else `gitea` if `X-Gitea-Event-Type` is present, else `github`. The specific headers are tested inside the GitHub branch because Forgejo and Gitea also set `X-GitHub-Event`. * `X-Gitlab-Event`: `gitlab`. * A `User-Agent` containing `bitbucket`: `bitbucket-cloud` when `actor.account_id` exists, `bitbucket-datacenter` when only `actor.id` exists, and `bitbucket-cloud` when neither can be read. * `X-Forgejo-Event-Type`, then `X-Gitea-Event-Type` on their own. * Last resort, the body: `repository.html_url` containing `github.com`, or `gitlab`; `project.web_url` containing `gitlab`; `repository.links.html.href` containing `bitbucket`. * Otherwise an error, `unable to detect provider from headers or payload`. ## Consequences * A self-hosted instance whose URL contains none of the substrings is only detected through headers; otherwise the user must pass `--provider`. * The Bitbucket Cloud versus Data Center split rests on the `actor` fields only. The code does not show that this holds for payloads without an `actor`; those fall back to cloud. * Header lookup is case-insensitive through `getHeaderCaseInsensitive`.