Documentation
¶
Overview ¶
Package githubapi serves the subset of GitHub's REST API that the actions running on ermite call under github.api_url (/-/github/api, ADR 0025 CI-2):
GET /repos/{owner}/{repo}
GET /repos/{owner}/{repo}/hash-algorithm
GET /repos/{owner}/{repo}/tarball[/{ref}]
GET /repos/{owner}/{repo}/pulls/{number}/files (dorny/paths-filter on pull_request)
Everything else under the prefix is GitHub's 404 JSON, so that an action calling an endpoint of a feature ermite lacks fails as it does on a GitHub instance without it, never silently succeeds. The auth is the forge's: a token (stored, or the repository token of a job) as the password of Basic with any user, or as "Bearer" or "token" credentials; no credentials is anonymous, which reads public repositories.
Index ¶
Constants ¶
const ( // DefaultMaxArchives is the archives written at once on the server. DefaultMaxArchives = 16 // DefaultMaxArchivesPerClient is the archives written at once for one client // (see clientlimit.Key). A runner host runs several jobs at once, each // downloading its actions, and all come from one address; eight is half of // the server's slots, so one host cannot take them all. Beyond it the answer // is 429 with Retry-After: the runner waits and tries again. DefaultMaxArchivesPerClient = 8 // DefaultWriteIdleTimeout is how long a write of the archive may wait for the // client. The deadline moves forward with every chunk: an archive is bounded // by its size, not by its duration, but a client that stops reading is cut. DefaultWriteIdleTimeout = 2 * time.Minute )
Bounds on the archives written at once.
const Prefix = "/-/github/api"
Prefix is where the API is mounted.
Variables ¶
var Patterns = []string{Prefix + "/"}
Patterns are the ServeMux patterns the handler serves: its whole prefix.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Auth ports.AuthService
API ports.GitHubAPIService
// TrustedProxies are the networks allowed to set X-Forwarded-For.
TrustedProxies []netip.Prefix
// Limiter counts failed authentications; nil builds a default one.
Limiter ports.FailureLimiter
// MaxArchives bounds the archives written at once (each runs a git
// process); zero means DefaultMaxArchives. MaxArchivesPerClient bounds them
// per client; zero means DefaultMaxArchivesPerClient. WriteIdleTimeout is
// the idle write deadline; zero means DefaultWriteIdleTimeout.
MaxArchives int
MaxArchivesPerClient int
WriteIdleTimeout time.Duration
}
Config configures a Handler.