Documentation
¶
Overview ¶
Package repoaccess is the wire contract of the integration-controller's internal repository-access endpoint, and the client the status server calls it with.
The status server holds no forge credential, so it cannot ask GitHub whether patchy can read a repository's alerts. The integration-controller can: it holds the Integration credentials already. It answers POST /internal/v1/repository-access on a separate in-cluster listener, authenticating the caller by an audience-bound projected ServiceAccount token (internal/tokenauth). The answer, per repository and Integration, is whether each enabled alert family is readable, plus whether a Forge covers the repository with write access for remediation.
Index ¶
Constants ¶
const ( // Path is the endpoint's route on the internal listener. Path = "/internal/v1/repository-access" // TokenHeader carries the caller's projected ServiceAccount token. TokenHeader = "X-Patchy-Caller-Token" // Audience is the projected-token audience the endpoint accepts. Audience = "patchy-integration-controller" // MaxRepositories bounds one request: each repository costs a few GitHub // API requests per Integration. MaxRepositories = 20 )
The endpoint's fixed contract.
const ( ContentsNone = "none" ContentsRead = "read" ContentsWrite = "write" ContentsUnknown = "unknown" // a PAT: patchy cannot see its scopes )
Contents permission levels a Forge credential reports.
Variables ¶
ErrUnavailable reports that the endpoint is not configured.
Functions ¶
func ValidRepository ¶
ValidRepository reports whether s is an exact "owner/name".
Types ¶
type Alerts ¶
type Alerts struct {
CodeScanning *Check `json:"codeScanning,omitempty"`
SecretScanning *Check `json:"secretScanning,omitempty"`
}
Alerts holds one check per alert family the Integration ingests; a family it does not ingest is absent.
type Client ¶
type Client struct {
// URL is the integration-controller's internal base URL.
URL string
// TokenFile is the projected ServiceAccount token; it is read again on
// every call, because the kubelet rotates it.
TokenFile string
// HTTP defaults to a client with a 30-second timeout.
HTTP *http.Client
}
Client calls the endpoint. The zero URL disables it (Check returns ErrUnavailable).
type ForgeAccess ¶
type ForgeAccess struct {
// Name is the covering Forge, empty when none covers it.
Name string `json:"name,omitempty"`
Status ForgeStatus `json:"status"`
// Contents is the credential's contents permission (Contents*).
Contents string `json:"contents,omitempty"`
Detail string `json:"detail,omitempty"`
}
ForgeAccess is the Forge coverage of one repository.
type ForgeStatus ¶
type ForgeStatus string
ForgeStatus is whether a Forge can remediate the repository.
const ( // ForgeOK: a Forge covers the repository, and its credential can write // contents (or is a PAT, whose scope patchy cannot see). ForgeOK ForgeStatus = "ok" // ForgeMissing: no Forge covers the repository. ForgeMissing ForgeStatus = "missing" // ForgeAmbiguous: several Forges cover it equally. ForgeAmbiguous ForgeStatus = "ambiguous" // ForgeNoWrite: the covering Forge's App cannot write contents. ForgeNoWrite ForgeStatus = "no_write" // ForgeError: the check itself failed. ForgeError ForgeStatus = "error" )
Forge coverage statuses.
type IntegrationAccess ¶
IntegrationAccess is one Integration's view of one repository.
func (IntegrationAccess) Readable ¶
func (ia IntegrationAccess) Readable() bool
Readable reports whether any of the Integration's alert families answered.
type Request ¶
type Request struct {
// Repositories are exact "owner/name" entries, at most MaxRepositories.
Repositories []string `json:"repositories"`
}
Request is the endpoint's body.
type Response ¶
type Response struct {
Results []Result `json:"results"`
}
Response is the endpoint's answer: one result per requested repository, in request order.
type Result ¶
type Result struct {
Repo string `json:"repo"`
// Integrations are the eligible github Integrations (not suspended,
// with an alert family enabled), sorted by name.
Integrations []IntegrationAccess `json:"integrations"`
// Forge reports remediation coverage.
Forge *ForgeAccess `json:"forge,omitempty"`
}
Result is one repository's access.
func (Result) Backfillable ¶
Backfillable returns the first Integration, by name, that can read the repository's alerts: the one a one-repository backfill is stamped on.