github

package
v0.3.103-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package github implements gitprovider.GitProvider against GitHub via go-github.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App reads GitHub as the GitHub App: a JWT signed with its private key mints a token per installation (ADR 0144).

func NewApp

func NewApp(clientID string, key *rsa.PrivateKey, now func() time.Time, opts ...Option) *App

NewApp builds an App signing as clientID; now defaults to time.Now.

func (*App) AccountOf

func (a *App) AccountOf(ctx context.Context, owner, name string) (int64, error)

AccountOf is the id of the account whose installation covers owner/name.

func (*App) CloneToken

func (a *App) CloneToken(ctx context.Context, owner, name string) (string, error)

CloneToken mints a token that reads only owner/name's contents, what a runner clones with; it is never cached, so no other repository or permission of the installation ever reaches a runner.

func (*App) ForRepo

func (a *App) ForRepo(ctx context.Context, owner, name string) (*Client, error)

ForRepo is a Client reading owner/name with its installation's token.

func (*App) InstallationAccounts

func (a *App) InstallationAccounts(ctx context.Context) ([]*gitprovider.Installation, error)

InstallationAccounts lists every installation of the App with its account, one request per hundred.

func (*App) InstallationToken

func (a *App) InstallationToken(ctx context.Context, id int64) (string, error)

InstallationToken returns a token for installation id, minted once and reused until shortly before it expires.

type AppCache

type AppCache struct {
	// Reresolve answers a rejected private key with its fresh PEM when its secret manager has one.
	Reresolve func(ctx context.Context, stale string) (string, bool)
	// contains filtered or unexported fields
}

AppCache keeps one App per key, client ID and server, so its tokens outlive the request that minted them.

func (*AppCache) Get

func (c *AppCache) Get(clientID, privateKey, baseURL string) (*App, error)

Get returns the App for these settings, building it on first use or after any of them changed.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the go-github-backed GitProvider implementation.

func New

func New(token string, opts ...Option) *Client

New builds a GitHub client; an empty token sends no auth header, giving unconfigured workspaces public access.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, owner, name string, in gitprovider.IssueInput) (*gitprovider.Issue, error)

CreateIssue implements gitprovider.GitProvider.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, owner, name string, number int, body string) (*gitprovider.IssueComment, error)

CreateIssueComment implements gitprovider.GitProvider.

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, owner, name string, cfg gitprovider.WebhookConfig) (string, error)

CreateWebhook implements gitprovider.GitProvider, returning the hook id.

func (*Client) DeleteIssueComment

func (c *Client) DeleteIssueComment(ctx context.Context, owner, name string, commentID int64) error

DeleteIssueComment implements gitprovider.GitProvider.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, owner, name, hookID string) error

DeleteWebhook implements gitprovider.GitProvider.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, owner, name, ref, filePath string) ([]byte, error)

GetFile implements gitprovider.GitProvider: a file's decoded content at ref, resolving ref to the repo's default branch via GetRepo when empty.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, owner, name string, number int) (*gitprovider.Issue, error)

GetIssue implements gitprovider.GitProvider.

func (*Client) GetPR

func (c *Client) GetPR(ctx context.Context, owner, name string, number int) (*gitprovider.PR, error)

GetPR implements gitprovider.GitProvider.

func (*Client) GetRepo

func (c *Client) GetRepo(ctx context.Context, owner, name string) (*gitprovider.Repo, error)

GetRepo implements gitprovider.GitProvider.

func (*Client) GetTree

func (c *Client) GetTree(ctx context.Context, owner, name, ref string) ([]gitprovider.TreeEntry, error)

GetTree implements gitprovider.GitProvider: the recursive tree at ref, resolving ref to the repo's default branch via GetRepo when empty.

func (*Client) ListInstallationRepos

func (c *Client) ListInstallationRepos(ctx context.Context) ([]*gitprovider.Repo, error)

ListInstallationRepos lists every repository across every App installation the user's token grants, fetched a page of installations at a time, a page of repos at a time.

func (*Client) ListInstallations

func (c *Client) ListInstallations(ctx context.Context) ([]*gitprovider.Installation, error)

ListInstallations lists the App installations the user's token sees; only a "selected" installation costs a second request, a one-item page read for its total_count.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(ctx context.Context, owner, name string, number int, since time.Time) ([]*gitprovider.IssueComment, error)

ListIssueComments implements gitprovider.GitProvider: every comment on issue number updated at or after since, all pages.

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context, owner, name string, opts gitprovider.IssueOpts) ([]*gitprovider.Issue, int, error)

ListIssues implements gitprovider.GitProvider: one page of issues, pull requests left out, and the next page, 0 after the last.

func (*Client) ListPRs

func (c *Client) ListPRs(ctx context.Context, owner, name string, opts gitprovider.PROpts) ([]*gitprovider.PR, error)

ListPRs implements gitprovider.GitProvider.

func (*Client) ListWebhooks

func (c *Client) ListWebhooks(ctx context.Context, owner, name string) ([]gitprovider.Webhook, error)

ListWebhooks implements gitprovider.GitProvider.

func (*Client) MergedInto

func (c *Client) MergedInto(ctx context.Context, owner, name string, number int, sha string) (bool, error)

MergedInto implements gitprovider.GitProvider through GitHub's compare of the pull request's merge commit with sha.

func (*Client) PRsForCommit

func (c *Client) PRsForCommit(ctx context.Context, owner, name, sha string) ([]*gitprovider.PR, error)

PRsForCommit implements gitprovider.GitProvider.

func (*Client) RateLimit

func (c *Client) RateLimit(ctx context.Context) (gitprovider.Rate, error)

RateLimit implements gitprovider.RateReader.

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(ctx context.Context, owner, name string, number int, p gitprovider.IssuePatch) (*gitprovider.Issue, error)

UpdateIssue implements gitprovider.GitProvider, sending only the fields the patch sets.

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(ctx context.Context, owner, name string, commentID int64, body string) (*gitprovider.IssueComment, error)

UpdateIssueComment implements gitprovider.GitProvider.

func (*Client) UpdateWebhook

func (c *Client) UpdateWebhook(ctx context.Context, owner, name, hookID string) error

UpdateWebhook implements gitprovider.GitProvider, setting the hook's events to webhookEvents.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(u *url.URL) Option

WithBaseURL points the client at a different API root (tests, GHE, Gitea).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL