Documentation
¶
Overview ¶
Package github adapts GitHub App REST, OAuth and webhook wire formats. It holds no storage and no diffx policy.
Index ¶
- Variables
- func ParseEvent(event string, body []byte) (any, error)
- func ParsePrivateKey(pemBytes []byte) (*rsa.PrivateKey, error)
- type Account
- type App
- type AuthorizationEvent
- type Client
- func (c *Client) AppSlug(ctx context.Context) (string, error)
- func (c *Client) AuthorizeURL(state, redirectURI string) string
- func (c *Client) Exchange(ctx context.Context, code, redirectURI string) (UserToken, error)
- func (c *Client) InstallationToken(ctx context.Context, installationID int64, repositoryIDs []int64, ...) (Token, error)
- func (c *Client) OpenPullRequests(ctx context.Context, installationID int64, fullName string) ([]PullRequest, error)
- func (c *Client) PullRequest(ctx context.Context, installationID int64, fullName string, number int) (PullRequest, error)
- func (c *Client) Refresh(ctx context.Context, refreshToken string) (UserToken, error)
- func (c *Client) User(ctx context.Context, accessToken string) (Account, error)
- func (c *Client) UserRepositories(ctx context.Context, accessToken string) ([]Repository, error)
- func (c *Client) VerifyWebhook(body []byte, signature256 string) bool
- type Error
- type InstallationEvent
- type InstallationRepositoriesEvent
- type Option
- type PullRequest
- type PullRequestEvent
- type Ref
- type Repository
- type Token
- type UserToken
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnauthorized matches 401 responses and rejected OAuth codes or refresh tokens. ErrInvalidRepository = errors.New("github: repository must be owner/name") )
Functions ¶
func ParseEvent ¶
ParseEvent decodes a verified webhook body by X-GitHub-Event name. It returns PullRequestEvent, InstallationEvent, InstallationRepositoriesEvent or AuthorizationEvent, and (nil, nil) for events diffx ignores, including ping.
func ParsePrivateKey ¶
func ParsePrivateKey(pemBytes []byte) (*rsa.PrivateKey, error)
ParsePrivateKey accepts PKCS#1 ("RSA PRIVATE KEY") or PKCS#8 ("PRIVATE KEY") PEM.
Types ¶
type AuthorizationEvent ¶
AuthorizationEvent reports a user revoking the app (github_app_authorization).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AuthorizeURL ¶
func (*Client) InstallationToken ¶
func (c *Client) InstallationToken(ctx context.Context, installationID int64, repositoryIDs []int64, permissions map[string]string) (Token, error)
InstallationToken mints a token narrowed to repositoryIDs and permissions when given.
func (*Client) OpenPullRequests ¶
func (c *Client) OpenPullRequests(ctx context.Context, installationID int64, fullName string) ([]PullRequest, error)
OpenPullRequests returns at most 3000 open pull requests.
func (*Client) PullRequest ¶
func (*Client) UserRepositories ¶
UserRepositories lists repositories both the user and the app can access, tagged with their installation and capped at 10000.
type InstallationEvent ¶
InstallationEvent.Action is created, deleted, suspend, unsuspend or new_permissions_accepted.
type InstallationRepositoriesEvent ¶
type InstallationRepositoriesEvent struct {
Action string
InstallationID int64
Added []Repository
Removed []Repository
}
type Option ¶
type Option func(*Client)
func WithAPIURL ¶
func WithHTTPClient ¶
func WithWebURL ¶
WithWebURL sets the origin of the OAuth authorize and token endpoints.
type PullRequest ¶
type PullRequest struct {
Number int
State string
Merged bool
Draft bool
Title string
Body string
HTMLURL string
Author Account
Base Ref
Head Ref
CreatedAt time.Time
UpdatedAt time.Time
}
PullRequest.Head.Repository is zero when the head fork was deleted.
type PullRequestEvent ¶
type PullRequestEvent struct {
Action string
InstallationID int64
Repository Repository
Number int
}
type Ref ¶
type Ref struct {
Ref string
SHA string
Repository Repository
}