events

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(err error) events.ALBTargetGroupResponse

ErrorResponse returns a 500 ALB response with a body generated from the provided error.

func ForbiddenResponse

func ForbiddenResponse() events.ALBTargetGroupResponse

ForbiddenResponse returns a 403 ALB response.

func GetWebhookTypeHTTPHeaders

func GetWebhookTypeHTTPHeaders(headers http.Header) string

GetWebhookTypeHTTPHeaders gets the webhook type from http-type headers.

func GetWebhookTypeLambdaHeaders

func GetWebhookTypeLambdaHeaders(headers map[string]string) string

GetWebhookTypeLambdaHeaders gets the webhook type from lambda-type headers.

func OKResponse

func OKResponse(body string) events.ALBTargetGroupResponse

OKResponse returns a 200 ALB response with the provided body.

func ValidateSignatureHTTPHeaders

func ValidateSignatureHTTPHeaders(headers http.Header, body []byte, secret string) error

ValidateSignatureHTTPHeaders validates a github webhook signature assuming http-formatted headers.

func ValidateSignatureLambdaHeaders

func ValidateSignatureLambdaHeaders(headers map[string]string, body []byte, secret string) error

ValidateSignatureLambdaHeaders validates a github webhook signature assuming lambda-formatted headers.

Types

type WebhookContext

type WebhookContext struct {
	// contains filtered or unexported fields
}

WebhookContext represents the full context of a webhook call from Github. It includes details on the pull request, comment, repo, etc.

func NewWebhookContext

func NewWebhookContext(
	webhookType string,
	webhookBody []byte,
	githubToken string,
) (*WebhookContext, error)

NewWebhookContext converts a webhook object into a WebhookContext, if possible.

func (*WebhookContext) Close

func (w *WebhookContext) Close() error

Close closes the underlying clients associated with this WebhookContext.

type WebhookHandler

type WebhookHandler struct {
	// contains filtered or unexported fields
}

WebhookHandler is a struct that handles incoming Github webhooks. Depending on the webhook details, it may make changes in one or more Kubernetes clusters, post comments back in the pull request, etc.

func NewWebhookHandler

func NewWebhookHandler(
	statsClient stats.StatsClient,
	clientGenerator cluster.ClusterClientGenerator,
	settings WebhookHandlerSettings,
) *WebhookHandler

NewWebhookHandler creates a new WebhookHandler from the provided clients and settings.

func (*WebhookHandler) HandleWebhook

func (whh *WebhookHandler) HandleWebhook(
	ctx context.Context,
	webhookContext *WebhookContext,
) events.ALBTargetGroupResponse

HandleWebhook processes a single WebhookContext, returning an ALB response that should be passed back to the client.

type WebhookHandlerSettings

type WebhookHandlerSettings struct {
	// ApplyConsistencyCheck indicates whether we should check that the SHA of an apply matches
	// the SHA of the last diff for the cluster.
	ApplyConsistencyCheck bool

	// Automerge indicates whether the handler should automatically merge changes after applies
	// have been made successfully in all clusters.
	Automerge bool

	// Debug indicates whether we should enable debug-level logging on kubectl calls.
	Debug bool

	// Env is the environment for this handler.
	Env string

	// LogsURL is the URL that should be used
	LogsURL string

	// StrictCheck indicates whether we should block applies on having an approval and all
	// green statuses.
	//
	// Note: To be deprecated and replaced with CICheck and ReviewRequired below.
	StrictCheck bool

	// GreenCIRequired indicates whether CI must be green before allowing applies.
	GreenCIRequired bool

	// ReviewRequired indicates whether a review is required before allowing applies.
	ReviewRequired bool

	// UseLocks indicates whether we should use locking to prevent overlapping handler calls
	// for a cluster.
	UseLocks bool

	// Version is the version of the lambda that invokes this handler.
	Version string
}

WebhookHandlerSettings stores the settings associated with a WebhookHandler.

Jump to

Keyboard shortcuts

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