--- title: "ADR 0023: Gitea API client construction" --- * Status: accepted * Code: [`pkg/provider/gitea/gitea.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/gitea/gitea.go) (`SetClient`, `Client`, `Provider.Password`) ## Context `SetClient` builds the `forgejo.Client` used for every later API call. Three constraints shape it: * `forgejo.NewClient` performs a version check against the server as part of construction. * The Repository CRD carries a token (`git_provider.secret`) but no password field. * One PAC installation can serve several Gitea instances, and API usage metrics are recorded per call in `Client()`. ## Decision * When `EnableAPIRetry` is set, the retry transport (`retryhttp.Wrap`) is installed through `forgejo.SetHTTPClient` before `forgejo.NewClient` is called, so the initial version check is retried as well as later calls. * Basic auth is used only when both `Provider.Password` and `runevent.Provider.User` are set. `Password` is exported for the e2e tests and is never populated from the Repository CRD. Otherwise a token is required and its absence is an error. * `Client()` records API usage labelled with `giteaInstanceURL` (the provider URL) rather than a constant `"gitea"`, so a cluster serving several Gitea instances can tell them apart. * The client initialisation is logged at info level with the user and provider URL, as an audit trail of client access. ## Consequences * Moving the retry options after `NewClient` would leave the version check unprotected against transient failures. * Password auth cannot be reached from a Repository CR; do not expect it in production flows. * Metrics are keyed by instance URL, so label cardinality grows with the number of Gitea instances.