Documentation
¶
Overview ¶
Package github is the ingestion.ForgeClient adapter for GitHub, backed by google/go-github.
Index ¶
- Variables
- type Client
- func (c *Client) CancelRun(ctx context.Context, req ingestion.RunActionRequest) error
- func (c *Client) CreateWebhook(ctx context.Context, req ingestion.CreateWebhookRequest) error
- func (c *Client) GetRepo(ctx context.Context, req ingestion.GetRepoRequest) (ingestion.RepoMetadata, error)
- func (c *Client) JobLogTail(ctx context.Context, req ingestion.JobLogRequest) (ingestion.JobLogTail, error)
- func (c *Client) ListAccessibleRepos(ctx context.Context, req ingestion.ListAccessibleReposRequest) ([]string, error)
- func (c *Client) ListRecentRuns(ctx context.Context, req ingestion.ListRunsRequest) (ingestion.ListRunsResult, error)
- func (c *Client) RateLimitFor(token string) (ingestion.RateLimitSnapshot, bool)
- func (c *Client) RerunRun(ctx context.Context, req ingestion.RunActionRequest) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIdentifier = errors.New("identifier must be in owner/name form")
ErrInvalidIdentifier is returned when a repo identifier isn't "owner/name".
var ErrUnexpectedStatus = errors.New("unexpected status")
ErrUnexpectedStatus is returned when a GitHub API response's status code is neither the expected success code nor 304 Not Modified.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the GitHub-backed ingestion.ForgeClient.
func NewClient ¶
NewClient returns a Client. baseURL overrides the GitHub API endpoint (for tests against a fake server); pass "" to use the real GitHub API.
func (*Client) CreateWebhook ¶
CreateWebhook implements ingestion.ForgeClient.
func (*Client) GetRepo ¶ added in v0.31.1
func (c *Client) GetRepo(ctx context.Context, req ingestion.GetRepoRequest) (ingestion.RepoMetadata, error)
GetRepo implements ingestion.ForgeClient. A single-repo lookup, not ListAccessibleRepos filtered client-side -- the authoritative check registration needs, independent of whatever a prior Discover call saw.
func (*Client) JobLogTail ¶ added in v0.70.0
func (c *Client) JobLogTail(ctx context.Context, req ingestion.JobLogRequest) (ingestion.JobLogTail, error)
JobLogTail implements ingestion.JobLogReader. GitHub answers GET .../actions/jobs/{id}/logs with a 302 to a plain-text download that expires after a minute (https://docs.github.com/en/rest/actions/workflow-jobs), so the redirect is followed here and the download URL never leaves the server. net/http drops the Authorization header on a cross-host redirect, which is what the download wants.
func (*Client) ListAccessibleRepos ¶ added in v0.11.0
func (c *Client) ListAccessibleRepos(ctx context.Context, req ingestion.ListAccessibleReposRequest) ([]string, error)
ListAccessibleRepos implements ingestion.ForgeClient. Returns every repo (owner, collaborator, and organization-member repos) the token can see, newest-pushed first, excluding archived, forked, and mirror repos -- none of the three is something the registration UI's picker should ever offer to track.
func (*Client) ListRecentRuns ¶ added in v0.4.0
func (c *Client) ListRecentRuns(ctx context.Context, req ingestion.ListRunsRequest) (ingestion.ListRunsResult, error)
ListRecentRuns implements ingestion.ForgeClient. The run-list request is conditional (If-None-Match/ETag); a 304 short-circuits before any jobs are fetched, since nothing about the run list changed. go-github's typed client isn't used here -- CheckResponse treats a 304 as an API error, so a plain net/http request keeps the conditional-GET contract explicit and testable against a fake server.
Below that per-list check, each individual run gets its own, finer- grained skip: a run present in req.KnownRuns whose status is completed and matches the fresh listing's status and conclusion has nothing new to report, so its jobs aren't refetched at all (see ingestion.RunState's doc comment).
func (*Client) RateLimitFor ¶ added in v0.25.0
func (c *Client) RateLimitFor(token string) (ingestion.RateLimitSnapshot, bool)
RateLimitFor implements ingestion.RateLimitReporter.
func (*Client) RerunRun ¶ added in v0.70.0
RerunRun implements ingestion.RunActor. It re-runs only the failed jobs when asked to, the whole run otherwise (https://docs.github.com/en/rest/actions/workflow-runs).