Documentation
¶
Overview ¶
Package github is the broker's GitHub App client (SP2 design §3, ruling P28). It posts an agent's review verdict as one pull request comment, as SP3's factory App, and reads who a GitHub user is and what they may read, for room visibility (D7).
Index ¶
- Variables
- func Permanent(err error) bool
- func Quote(s string) string
- type APIError
- type App
- func (a *App) Comment(ctx context.Context, pr, marker, body string) (string, error)
- func (a *App) Enabled() bool
- func (a *App) Permission(ctx context.Context, owner, repo, login string) (string, error)
- func (a *App) Repository(ctx context.Context, owner, repo string) (Repository, error)
- func (a *App) UserLogin(ctx context.Context, owner, repo string, id int64) (string, error)
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ErrNoInstallation = errors.New("github: the App is not installed on the repository, or it does not exist")
ErrNoInstallation reports a repository GitHub knows no installation of the App on: it does not exist, or the App is not installed there. It wraps GitHub's 404, which stays permanent.
var ErrNotAPullRequest = errors.New("github: not a GitHub pull request URL")
ErrNotAPullRequest reports a URL that is not a GitHub pull request's.
var ErrTooManyComments = errors.New("github: too many comments to search for the marker")
ErrTooManyComments reports a pull request with more comments than the client searches, so it cannot know whether the App already posted, and does not post.
Functions ¶
func Permanent ¶
Permanent reports an error a retry cannot heal: GitHub's 4xx other than a rate limit or a 401, a URL that names no pull request, or one too long to search. A key that cannot be read, that is no App id's, or that GitHub rejects is not: the owner's Secret can still land or be fixed (ruling SZ).
func Quote ¶
Quote makes untrusted text, an agent's verdict summary, inert in a pull request comment: a fenced code block that nothing in the text can close, because its fence is longer than any run of backticks the text holds. GitHub renders a code block as text only: no mention notifies anyone, no cross-reference (a URL, #N, GH-N, owner/repo#N, a SHA) backlinks another issue, no image loads and no HTML renders, a marker included (reviews 3.4 I1, 3.5 m3). Hidden characters go first: format and control characters but newline and tab, every other default-ignorable code point and the variation selectors (bidi overrides, zero-width joiners, the BOM, soft hyphens, escapes).
Types ¶
type APIError ¶
APIError is a GitHub answer outside 2xx. It names the status and path only: a reply body can quote a credential. RateLimited marks a 403 or 429 that is GitHub's primary or secondary rate limit, and RetryAfter is when it lifts, when GitHub says.
func (*APIError) Permanent ¶
Permanent reports a 4xx other than a rate limit or a 401, which a retry does not heal (the App is not installed, the pull request is gone, the comment is refused). A 401 that survives Comment's fresh-token retry is a key GitHub rejects, which the operator can fix (ruling SZ).
type App ¶
type App struct {
Dir string
API string
HC *http.Client
Now func() time.Time
// contains filtered or unexported fields
}
App reads its id and key from Dir (app_id, private_key) at every mint. Dir is an optional Secret volume that kubelet fills once the owner has written the key (ruling P31), so the broker needs no restart and has no startup race. API is GitHub's https API base, HC the httpx egress client, Now the clock: all three are required.
func (*App) Comment ¶
Comment posts body, then marker, on the pull request, once. The App's own comment that already ends with marker is returned instead: a retry after a crash, or a new leader. Another author's copy of the marker never counts. Calls for one marker run one at a time; other markers are not held up.
func (*App) Permission ¶
Permission is login's permission on owner/repo as GitHub's collaborator API states it (admin, write, read or none), read with owner/repo's installation token, which metadata: read covers. GitHub's 404, a login it does not know or one with no access, is "none"; any other refusal is an error, never an answer, so the caller fails closed.
func (*App) Repository ¶ added in v0.35.0
Repository is owner/repo's visibility, read with its installation token, which metadata: read covers. It is the planner's public-only read (CD5, v3.x conversational intake): public text only, decided once per repository by the caller's cache rather than by a model.
A repository GitHub does not show the App — no installation, or a 404 for its scoped token — is ErrNoInstallation, and a reply with no visibility word is an error: neither is an answer, so the caller refuses rather than planning on a guess.
type Repository ¶ added in v0.35.0
Repository is one repository as GitHub's repository API states it: Private whether GitHub reports it private, and Visibility GitHub's own word for it — "public", "private", or an enterprise's "internal", which is private to everyone outside it however much a token can see.