Documentation ¶
Index ¶
- Variables
- func CloneGitHubClientContext(parent, source context.Context) context.Context
- func GetGitHubAppClient(ctx context.Context, alt *github.Client) *github.Client
- func GetGitHubInstallationClient(ctx context.Context, alt *github.Client) *github.Client
- func NewGitHubClientContext(ctx context.Context, installationID int64, gha GithubAppClientFactory) context.Context
- type GitHubApp
- type GitHubClientContextKey
- type GitHubInstallationIDContextKey
- type GithubAppClientFactory
- type PRCallback
Constants ¶
This section is empty.
Variables ¶
var ( GitHubV3APIURL = "https://api.github.com/" GitHubV4APIURL = "https://api.github.com/graphql" )
Functions ¶
func CloneGitHubClientContext ¶
CloneGitHubClientContext copies GitHub client values from source to a new context descended from parent If GitHub client values are missing from source, parent is returned
func GetGitHubAppClient ¶
GetGitHubAppClient returns the GitHub app client embedded in ctx if present or the alternate client provided by caller
func GetGitHubInstallationClient ¶
GetGitHubInstallationClient returns the GitHub installation client embedded in ctx if present or the alternate client provided by caller
func NewGitHubClientContext ¶
func NewGitHubClientContext(ctx context.Context, installationID int64, gha GithubAppClientFactory) context.Context
NewGitHubClientContext returns a context with the GitHub client factory from gha embedded as a value
Types ¶
type GitHubApp ¶
type GitHubApp struct {
// contains filtered or unexported fields
}
GitHubApp implements a GitHub app
func NewGitHubApp ¶
func NewGitHubApp(privateKeyPEM []byte, appID uint, webhookSecret string, supportedPRActions []string, prcb PRCallback, dl persistence.DataLayer) (*GitHubApp, error)
NewGitHubApp returns a GitHubApp with the given private key, app ID and webhook secret, or error supportedPRActions is at least one PR webhook action that is supported (prcallback will be executed). Any unsupported actions will be ignored and the webhook request will be responded with 200 OK, "action not relevant".
type GitHubClientContextKey ¶
type GitHubClientContextKey string
type GitHubInstallationIDContextKey ¶
type GitHubInstallationIDContextKey string
type GithubAppClientFactory ¶
type GithubAppClientFactory interface { NewAppClient() (*github.Client, error) NewAppV4Client() (*githubv4.Client, error) NewInstallationClient(installationID int64) (*github.Client, error) NewInstallationV4Client(installationID int64) (*githubv4.Client, error) }
func GetGitHubClientValuesFromContext ¶
func GetGitHubClientValuesFromContext(ctx context.Context) (int64, GithubAppClientFactory, error)
type PRCallback ¶
PRCallback is a function that gets called when a validated, parsed PR webhook event is received - action is the PR webhook action string ("opened", "closed", "labeled", etc), see https://developer.github.com/v3/activity/events/types/#pullrequestevent - rrd is the parsed repo/revision information from the webhook payload - ctx is pre-populated with an eventlogger and authenticated GitHub clients (app and installation) If the callback returns a non-nil error, the webhook request client will be returned a 500 error with the error details in the body If the error is nil, the webhook client will be returned a 202 Accepted response with the eventlog ID