Documentation
¶
Overview ¶
Package gitea resolves versions from a Gitea or Forgejo forge's tags and releases. One provider serves every instance of the API: Codeberg (the default host), forgejo.org, and any self-managed Gitea/Forgejo, selected by the host key. Discovery is a single cached REST listing per marker; selection, cooldown, and filtering stay with the framework.
Index ¶
- func Login(ctx context.Context, host, clientID string, prompt func(authURL string)) error
- type Option
- type Provider
- func (p *Provider) AuthHint() string
- func (p *Provider) Authenticate(context.Context) error
- func (p *Provider) Describe(r provider.Resource) string
- func (p *Provider) Discover(ctx context.Context, r provider.Resource) ([]model.Candidate, error)
- func (p *Provider) Keys() []provider.Key
- func (p *Provider) Name() string
- func (p *Provider) Resource(d directive.Directive) (provider.Resource, error)
- func (p *Provider) URL(r provider.Resource, c model.Candidate) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Login ¶
Login authenticates clover with a Gitea/Forgejo host via the OAuth authorization-code flow with PKCE (RFC 8252): it binds a loopback listener, opens the browser to the host's authorize page through prompt, captures the redirected code, exchanges it for tokens, and persists them under the host so the credential chain finds them. host and clientID default to codeberg.org and Gitea's built-in public "tea" application. Gitea has no device flow, so this browser flow is the interactive login; it needs a local browser (not headless), which is fine for a one-time login command.
Types ¶
type Option ¶
type Option func(*Provider)
Option configures a Provider.
func WithStore ¶
func WithStore(s tokenStore) Option
WithStore sets the token store the credential chain reads a minted login from, for tests.
func WithToken ¶
WithToken injects a PAT credential directly, for tests exercising the authenticated path without reading the machine's environment.
func WithTransport ¶
func WithTransport(rt http.RoundTripper) Option
WithTransport overrides the HTTP transport, for tests. It also pins credential resolution away from ambient env vars (see staticCredential), so a test never reaches the network and its auth path stays deterministic.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider resolves versions from a Gitea/Forgejo project's tags or releases over a single cached REST client shared across a run. The host is per-marker (the API is the same on every instance), so the client is host-agnostic, each request carries its own absolute URL, and the credential is resolved per host - an env-var PAT is host-independent, but a token minted by `clover login` is stored under the host it authenticated.
func New ¶
New returns the Gitea provider. A token comes from CLOVER_GITEA_TOKEN, a login minted by `clover login gitea` (stored per host), or anonymous access applies. The default keychain store is wired only on the real transport: a test transport keeps auth explicit (WithToken/WithStore), so the machine's stored token never leaks into a test.
func (*Provider) Authenticate ¶
Authenticate reports whether a credential is available, without verifying it over the network or blocking on a prompt. It sees the host-independent PAT and a login stored under the default host; a login under a non-default host is keyed by host and only resolved at discovery, so this may under-report for those. Absence is reported as errAnonymous - informational, not fatal, since anonymous reads still work.