Documentation
¶
Overview ¶
Package github is RunLore's GitHub forge client (curation + re-investigation) over the GitHub REST API, authenticated with short-lived GitHub App installation tokens. It satisfies providers.CurationForge / providers.ReinvestForge / curate.Forge.
Index ¶
- Constants
- func ParsePrivateKey(pemData string) (*rsa.PrivateKey, error)
- type AppTokenSource
- type Client
- func (c *Client) Close(ctx context.Context, number int) error
- func (c *Client) Comment(ctx context.Context, number int, body string) error
- func (c *Client) ListClosedUnmergedPRsByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
- func (c *Client) ListIssuesByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
- func (c *Client) ListPRsByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
- func (c *Client) OpenIssue(ctx context.Context, inv providers.Investigation) (providers.Ref, error)
- func (c *Client) OpenPR(ctx context.Context, e providers.KBEntry) (providers.Ref, error)
- func (c *Client) ReplaceLabel(ctx context.Context, number int, remove, add string) error
- type TokenFunc
Constants ¶
const DefaultBaseURL = "https://api.github.com"
DefaultBaseURL is the public GitHub REST API. Override for GitHub Enterprise Server (e.g. https://ghe.example.com/api/v3) or tests.
Variables ¶
This section is empty.
Functions ¶
func ParsePrivateKey ¶
func ParsePrivateKey(pemData string) (*rsa.PrivateKey, error)
ParsePrivateKey parses a PEM-encoded RSA private key (PKCS#1 or PKCS#8).
Types ¶
type AppTokenSource ¶
type AppTokenSource struct {
// contains filtered or unexported fields
}
AppTokenSource mints and caches GitHub App installation tokens.
func NewAppTokenSource ¶
func NewAppTokenSource(baseURL string, appID, installID int64, key *rsa.PrivateKey) *AppTokenSource
NewAppTokenSource builds a token source from an App ID, installation ID, and RSA private key. baseURL may be empty (defaults to DefaultBaseURL).
func (*AppTokenSource) Token ¶
func (s *AppTokenSource) Token(ctx context.Context) (string, error)
Token returns a valid installation token, refreshing when near expiry. The network refresh runs WITHOUT holding the lock (double-checked locking), so a slow/hung GitHub round-trip can't block every other token consumer.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GitHub forge client scoped to one repo.
func New ¶
New builds a client. baseURL may be empty (defaults to DefaultBaseURL); baseBranch is the PR target (e.g. "main").
func (*Client) ListClosedUnmergedPRsByLabel ¶ added in v0.4.0
func (c *Client) ListClosedUnmergedPRsByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
ListClosedUnmergedPRsByLabel returns closed PRs carrying the label that were NOT merged — the KB entries a human deliberately rejected. Merged PRs (accepted entries) and plain closed issues are filtered out. It drives the curate suppression set: a rejected entry that keeps recurring is escalated via a knowledge-gap issue, never reopened.
func (*Client) ListIssuesByLabel ¶
func (c *Client) ListIssuesByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
ListIssuesByLabel returns all open issues carrying the given label. Pull requests (which the issues API also returns) are filtered out.
func (*Client) ListPRsByLabel ¶
func (c *Client) ListPRsByLabel(ctx context.Context, label string) ([]providers.CuratedIssue, error)
ListPRsByLabel returns all open PRs carrying the given label — the inverse of ListIssuesByLabel (keeps only entries with a pull_request object).