Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrRateLimit = errors.New("rate limit hit") ErrAssetNotFound = errors.New("asset not found") ErrUnableToDownloadAsset = errors.New("unable to download asset") ErrUnableToReadAsset = errors.New("unable to download asset") ErrFatalError = errors.New("fatal error using github") )
var ( // ErrInvalidPrivateKey is returned when the PEM block cannot be parsed as an RSA private key. ErrInvalidPrivateKey = errors.New("invalid rsa private key") // ErrEmptyAppID is returned when app ID is empty. ErrEmptyAppID = errors.New("app id must not be empty") )
var ( // ErrEmptyInstallationID is returned when an installation ID is empty. ErrEmptyInstallationID = errors.New("installation id must not be empty") )
var ErrFieldUnexpectedlyNil = errors.New("expected field to be non-nil")
ErrFieldUnexpectedlyNil is returned when a field that is expected to be non-nil is found to be nil. A lot of GitHub API fields are pointers, so we need to check for nil values.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(token string, opts ...ClientOption) *Client
NewClient creates a new Github Client. If the token is not empty, it will use it as the auth token to make calls.
type ClientOption ¶
func WithBaseURL ¶
func WithBaseURL(baseURL *url.URL) ClientOption
type GitHubUser ¶
type InstallationTokenProvider ¶
type InstallationTokenProvider interface {
GetInstallationToken(ctx context.Context, installationID string) (string, error)
}
InstallationTokenProvider retrieves a valid installation access token for a GitHub App installation.
type ReleaseFile ¶
type ReleaseFile struct {
Contents io.ReadCloser
Info ReleaseInfo
}
ReleaseFile represents a file in a given Github release.
type ReleaseInfo ¶
type ReleaseInfo struct {
// If the tag is valid, the will be non null.
Tag *string
}
type RepoClient ¶
type TokenCacher ¶
type TokenCacher interface {
Get(ctx context.Context, key string) ([]byte, error)
Cache(ctx context.Context, key string, in []byte) error
}
TokenCacher caches installation access tokens.
type TokenProvider ¶
type TokenProvider struct {
// contains filtered or unexported fields
}
TokenProvider manages RS256 JWT minting and cached GitHub App installation access tokens.
func NewTokenProvider ¶
func NewTokenProvider(appID string, privateKeyPEM []byte, cacher TokenCacher) (*TokenProvider, error)
NewTokenProvider returns a new TokenProvider configured with the given cacher and standard HTTP transport. Validates appID and parses privateKeyPEM at construction time to fail fast on invalid credentials.
func (*TokenProvider) GetInstallationToken ¶
func (tp *TokenProvider) GetInstallationToken(ctx context.Context, installationID string) (string, error)
GetInstallationToken returns a valid GitHub App installation access token.
type UserGitHubClient ¶
type UserGitHubClient struct {
// contains filtered or unexported fields
}
UserGitHubClient is a client that receives a token from a user that has installed our GitHub App. It uses that token to make requests on behalf of that user to verify things about them. It is different from the regular Client which is used for internal operations.
func NewUserGitHubClient ¶
func NewUserGitHubClient(token string, opts ...ClientOption) *UserGitHubClient
NewUserGitHubClient creates a new UserGitHubClient with the given token. Assumes that the token is not empty.
func (*UserGitHubClient) GetCurrentUser ¶
func (c *UserGitHubClient) GetCurrentUser(ctx context.Context) (*GitHubUser, error)
func (*UserGitHubClient) ListEmails ¶
func (c *UserGitHubClient) ListEmails(ctx context.Context) ([]*UserEmail, error)
type UsersClient ¶
type WebhookVerifier ¶
type WebhookVerifier struct {
// contains filtered or unexported fields
}
WebhookVerifier validates incoming GitHub webhook signatures using HMAC SHA-256.
func NewWebhookVerifier ¶
func NewWebhookVerifier(secret []byte) *WebhookVerifier
NewWebhookVerifier creates a new WebhookVerifier with the provided secret.
func (*WebhookVerifier) VerifySignature ¶
func (v *WebhookVerifier) VerifySignature(payload []byte, headerSig string) error
VerifySignature verifies a GitHub HMAC SHA-256 webhook signature header (e.g. "sha256=...").