Documentation
¶
Overview ¶
Package github is a small GitHub Contents API client that lists the ebuild versions a repository holds for a package, with an on-disk response cache, rate-limit detection and a token resolved from the secrets chain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRateLimit indicates GitHub API rate limit exceeded ErrRateLimit = errors.New("GitHub API rate limit exceeded") // ErrNotFound indicates the requested resource was not found ErrNotFound = errors.New("package not found in repository") // ErrAPIError indicates a general GitHub API error ErrAPIError = errors.New("GitHub API error") // error carrying it also matches ErrAPIError. ErrUnauthorized = errors.New("GitHub authentication rejected") )
Functions ¶
func ResolveToken ¶
ResolveToken resolves a GitHub API token through the unified secrets chain, honouring GITHUB_TOKEN first then GH_TOKEN (the gh CLI convention). It returns ("", nil) when neither is set — anonymous access is allowed. A present-but- unreadable secrets file returns a non-nil error wrapping secrets.ErrUnreadable so a caller can warn rather than silently degrade to anonymous requests. This is the single source of truth for GitHub-token resolution.
Types ¶
type CacheEntry ¶
type CacheEntry struct {
Versions []string `json:"versions"`
Timestamp time.Time `json:"timestamp"`
}
CacheEntry represents a cached API response
type Client ¶
type Client struct {
BaseURL string
Repository string
UserAgent string
Token string // GitHub personal access token (optional, increases rate limit)
HTTPClient *http.Client
CacheDir string
CacheTTL time.Duration
}
Client handles communication with the GitHub API
func NewClientWithOptions ¶
NewClientWithOptions creates a new GitHub API client with custom options
func (*Client) GetPackageVersions ¶
GetPackageVersions fetches all ebuild versions for a package from GitHub
func (*Client) GetRateLimitInfo ¶
func (c *Client) GetRateLimitInfo(ctx context.Context) (remaining int, resetTime time.Time, err error)
GetRateLimitInfo returns current rate limit status. The request is bound to ctx: cancelling it aborts the lookup in flight, and the returned error wraps ctx.Err().
func (*Client) SetCacheDir ¶
SetCacheDir sets the cache directory for API responses