ghapp

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitHubV3APIURL = "https://api.github.com/"
	GitHubV4APIURL = "https://api.github.com/graphql"
)

Functions

func CloneGitHubClientContext

func CloneGitHubClientContext(parent, source context.Context) context.Context

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

func GetGitHubAppClient(ctx context.Context, alt *github.Client) *github.Client

GetGitHubAppClient returns the GitHub app client embedded in ctx if present or the alternate client provided by caller

func GetGitHubInstallationClient

func GetGitHubInstallationClient(ctx context.Context, alt *github.Client) *github.Client

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".

func (*GitHubApp) Handler

func (gha *GitHubApp) Handler() http.Handler

Handler returns the http.Handler that should handle the webhook HTTP endpoint

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

type PRCallback func(ctx context.Context, action string, rrd models.RepoRevisionData) error

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

Jump to

Keyboard shortcuts

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