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) Branches(ctx context.Context, r provider.Resource) ([]provider.Branch, error)
- func (p *Provider) Color(dark bool) color.Color
- func (p *Provider) Credentialed(r provider.Resource) bool
- func (p *Provider) Dated()
- func (p *Provider) DefaultBranch(ctx context.Context, r provider.Resource) (string, 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) DownloadAsset(ctx context.Context, r provider.Resource, asset model.Asset) (io.ReadCloser, error)
- func (p *Provider) Identify(r provider.Resource) (string, string)
- func (p *Provider) Keys() []provider.Key
- func (p *Provider) Name() string
- func (p *Provider) Reachable(ctx context.Context, r provider.Resource, branch, commit string) (bool, error)
- 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.
func (*Provider) Branches ¶ added in v0.3.10
Branches lists the repository's branches with their tip commits, for matching an allowed-branch pattern and the tip-equality fast path.
func (*Provider) Color ¶ added in v0.3.10
Color is the provider's brand color. See provider.Provider.Color.
func (*Provider) Credentialed ¶ added in v0.3.10
Credentialed reports whether a credential applies to the resource's host, satisfying provider.CredentialChecker. It gates the default verification tier. An expired login still counts when it carries a refresh token, since the next request renews it.
func (*Provider) Dated ¶ added in v0.2.8
func (p *Provider) Dated()
Dated marks the listing as date-bearing: releases carry a publication date. Bare tags do not, and fall to the post-discovery date check.
func (*Provider) DefaultBranch ¶ added in v0.3.10
DefaultBranch returns the repository's default branch, for tag-on-trunk verification when no explicit allowed-branch pattern is set.
func (*Provider) DownloadAsset ¶ added in v0.3.14
func (p *Provider) DownloadAsset( ctx context.Context, r provider.Resource, asset model.Asset, ) (io.ReadCloser, error)
DownloadAsset streams a release asset's content, satisfying provider.AssetDownloader. Gitea serves an uploaded asset's bytes at its browser URL (/attachments/<uuid>), which honors the API credential - its asset API endpoint returns JSON metadata, not bytes - so the browser URL is fetched with the credential attached whenever it sits on the forge host itself. An external-type asset points off-host and must not receive the token, and any redirect off the forge origin (a subdomain object store, a scheme downgrade) drops the header.
func (*Provider) Identify ¶ added in v0.3.10
Identify returns the owner/name repository and its landing page.
func (*Provider) Reachable ¶ added in v0.3.10
func (p *Provider) Reachable( ctx context.Context, r provider.Resource, branch, commit string, ) (bool, error)
Reachable reports whether commit is an ancestor of (or equal to) branch's tip, via the compare API.