Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// Service is a transport-agnostic webhook (event) handler.
Service Service
// Config encapsulates configuration for this Handler.
Config HandlerConfig
}
Handler is an implementation of the http.Handler interface that can handle webhooks (events) from GitHub by delegating to a transport-agnostic Service interface.
type HandlerConfig ¶
type HandlerConfig struct {
// GitHub App that sends webhooks (events) to this gateway. This secret can be
// used to validate the authenticity and integrity of payloads received by
// this gateway.
SharedSecret string
}
HandlerConfig encapsulates Handler configuration.
type Service ¶
type Service interface {
// Handle handles a GitHub webhook (event).
Handle(
ctx context.Context,
eventType string,
payload []byte,
) (core.EventList, error)
}
Service is an interface for components that can handle webhooks (events) from GitHub. Implementations of this interface are transport-agnostic.
func NewService ¶
func NewService( eventsClient core.EventsClient, config ServiceConfig, ) Service
NewService returns an implementation of the Service interface for handling (events) from GitHub.
type ServiceConfig ¶
type ServiceConfig struct {
// GithubAppID specifies the ID of a GitHub App.
GithubAppID int
// GithubAPIKey is the private API key for the GitHub App specified by the
// GithubAppID field.
GithubAPIKey []byte
// CheckSuiteAllowedAuthorAssociations enumerates the author associations who
// are allowed to have their PR events and "/brig check" or "/brig run"
// comments trigger the creation of a GitHub CheckSuite. Possible values are:
// COLLABORATOR, CONTRIBUTOR, OWNER, NONE, MEMBER, FIRST_TIMER, and
// FIRST_TME_CONTRIBUTOR.
CheckSuiteAllowedAuthorAssociations []string
// CheckSuiteOnPR specifies whether eligible PR events (see
// CheckSuiteAllowedAuthorAssociations) should trigger a corresponding suite
// of checks. Note that GitHub AUTOMATICALLY triggers such suites in response
// to push events, but as a security measure, does NOT do so for PR events,
// given that a PR may have originated from an untrusted user. Setting this
// field to true, when used in conjunction with the
// CheckSuiteAllowedAuthorAssociations field allows classes of trusted user
// (only) to have their PRs trigger check suites automatically.
CheckSuiteOnPR bool
// CheckSuiteOnComment specifies whether eligible comments (ones containing
// the text "/brig check" or "/brig run") should trigger a corresponding suite
// of checks. Note that this privilege is extended only to trusted classes of
// user specified by the CheckSuiteAllowedAuthorAssociations field.
CheckSuiteOnComment bool
// EmittedEvents enumerates specific event types that, when received by the
// gateway, should be emitted into Brigade's event bus. The value "*" can be
// used to indicate "all events." ONLY specified events are emitted. i.e. An
// empty list in this field will result in NO EVENTS being emitted into
// Brigade's event bus. This field is one of several useful controls for
// cutting down on the amount of noise that this gateway propagates into
// Brigade's event bus. (Another would be to configure the Brigade App itself
// to only send specific events to this gateway.)
EmittedEvents []string
}
ServiceConfig encapsulates configuration options for webhook-handling service.
Click to show internal directories.
Click to hide internal directories.