Documentation
¶
Overview ¶
Package github is a thin client for the pieces of the GitHub REST API forge-dashboard needs: which repositories the token can write to, their open pull requests and issues, and combined CI status per pull request. It's hand-written against net/http rather than a generated SDK — the surface area needed is small enough that a client library would cost more to pin and understand than it saves.
Index ¶
- type Client
- func (c *Client) ListOpenIssues(ctx context.Context, owner, name, repo string) ([]dashboard.Issue, error)
- func (c *Client) ListOpenPullRequests(ctx context.Context, owner, name, repo string) ([]dashboard.PullRequest, error)
- func (c *Client) ListRepos(ctx context.Context) ([]dashboard.RepoRef, error)
- func (c *Client) RateLimit(ctx context.Context) (dashboard.RateLimit, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the GitHub REST API, either as an authenticated user (a token) or anonymously against one user's public repositories (a username, no token at all).
func NewClient ¶
NewClient returns a Client. With token set, it authenticates as that user and ListRepos returns every repo the token can push to, private included. With token empty and username set, every request goes out unauthenticated and ListRepos returns only username's public repos — there's no "write access" to filter by without a credential, so this mode returns everything public GitHub already shows anyone. baseURL defaults to the real GitHub API; tests override it to point at an httptest.Server.
func (*Client) ListOpenIssues ¶
func (c *Client) ListOpenIssues(ctx context.Context, owner, name, repo string) ([]dashboard.Issue, error)
ListOpenIssues returns every open issue against repo — pull requests excluded, even though GitHub's issues endpoint returns both: an entry with a non-null pull_request field is a pull request wearing an issue number, not a real issue.
func (*Client) ListOpenPullRequests ¶
func (c *Client) ListOpenPullRequests(ctx context.Context, owner, name, repo string) ([]dashboard.PullRequest, error)
ListOpenPullRequests returns every open pull request against repo, with CI already resolved. repo is owner-qualified ("alrayyes/hush-hush").
func (*Client) ListRepos ¶
ListRepos returns the repositories this Client is configured to track — see NewClient for the two modes.
func (*Client) RateLimit ¶ added in v0.36.0
RateLimit reports the core REST API budget for this Client's credential (or, unauthenticated, the calling IP's own — a much smaller 60/hour budget, but the same shape). GitHub excludes this endpoint from the budget it reports, so calling it never itself moves the number it returns.