notify

package
v0.0.0-...-4a11b79 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Overview

Define the constants to use in notify

Index

Constants

View Source
const LOGDOG_REQUEST_TIMEOUT = 30 * time.Second

As Logdog request is a component of pubsub post request, LOGDOG_REQUEST_TIMEOUT should be smaller than PUBSUB_POST_REQUEST_TIMEOUT

View Source
const PUBSUB_POST_REQUEST_TIMEOUT = 60 * time.Second

Variables

This section is empty.

Functions

func BlamelistRepoWhiteset

func BlamelistRepoWhiteset(notifications notifypb.Notifications) stringset.Set

BlamelistRepoWhiteset computes the aggregate repository whitelist for all blamelist notification configurations in a given set of notifications.

func BuildbucketPubSubHandler

func BuildbucketPubSubHandler(ctx *router.Context, ct CloudTasksClient) error

BuildbucketPubSubHandler is the main entrypoint for a new update from buildbucket's pubsub.

This handler delegates the actual processing of the build to handleBuild. Its primary purpose is to unwrap context boilerplate and deal with progress-stopping errors.

func InitDispatcher

func InitDispatcher(d *tq.Dispatcher)

InitDispatcher registers the send email task with the given dispatcher.

func Notify

func Notify(c context.Context, ct CloudTasksClient, recipients []EmailNotify, templateParams *notifypb.TemplateInput) error

Notify discovers, consolidates and filters recipients from a Builder's notifications, and 'email_notify' properties, then dispatches notifications if necessary. Does not dispatch a notification for same email, template and build more than once. Ignores current transaction in c, if any.

func SendEmail

func SendEmail(c context.Context, task proto.Message) error

SendEmail is a push queue handler that attempts to send an email.

func ShouldNotify

func ShouldNotify(n *notifypb.Notification, oldStatus buildbucketpb.Status, newBuild *buildbucketpb.Build) (bool, []*buildbucketpb.Step)

ShouldNotify determines whether a trigger's conditions have been met, and returns the list of steps matching the filters on the notification, if any.

func UpdateTreeClosers

func UpdateTreeClosers(c context.Context, build *Build, oldStatus buildbucketpb.Status) error

UpdateTreeClosers finds all the TreeClosers that care about a particular build, and updates their status according to the results of the build.

func UpdateTreeStatus

func UpdateTreeStatus(c *router.Context)

UpdateTreeStatus is the HTTP handler triggered by cron when it's time to check tree closers and update tree status if necessary.

Types

type Build

type Build struct {
	BuildbucketHostname string
	buildbucketpb.Build
	EmailNotify []EmailNotify
}

Build is buildbucketpb.Build along with the parsed 'email_notify' values.

type Checkout

type Checkout map[string]string

Checkout represents a Git checkout of multiple repositories. It is a mapping of repository URLs to Git revisions.

func NewCheckout

func NewCheckout(commits notifypb.GitilesCommits) Checkout

NewCheckout creates a new Checkout populated with the repositories and revision found in the GitilesCommits object.

func (Checkout) Filter

func (c Checkout) Filter(whiteset stringset.Set) Checkout

Filter filters out repositories from the Checkout which are not in the whitelist and returns a new Checkout.

func (Checkout) ToGitilesCommits

func (c Checkout) ToGitilesCommits() notifypb.GitilesCommits

ToGitilesCommits converts the Checkout into a set of GitilesCommits which may be stored as part of a config.Builder.

type CheckoutFunc

type CheckoutFunc func(context.Context, *Build) (Checkout, error)

CheckoutFunc is a function that given a Build, produces a source checkout related to that build.

type CloudTasksClient

type CloudTasksClient interface {
	CreateTask(ctx context.Context, queue string, task *taskspb.Task) (*taskspb.Task, error)
	ProjectID() string
	LocationID() string
}

type EmailNotify

type EmailNotify struct {
	Email         string `json:"email"`
	Template      string `json:"template"`
	MatchingSteps []*buildbucketpb.Step
}

EmailNotify contains information for delivery and personalization of notification emails.

func ComputeRecipients

func ComputeRecipients(c context.Context, notifications []ToNotify, inputBlame []*gitpb.Commit, outputBlame Logs) []EmailNotify

ComputeRecipients computes the set of recipients given a set of notifications, and potentially "input" and "output" blamelists.

An "input" blamelist is computed from the input commit to a build, while an "output" blamelist is derived from output commits.

type HistoryFunc

type HistoryFunc func(ctx context.Context, luciProject, gerritHost, gerritProject, oldRevision, newRevision string) ([]*gitpb.Commit, error)

HistoryFunc is a function that gets a list of commits from Gitiles for a specific repository, between oldRevision and newRevision, inclusive.

If oldRevision is not reachable from newRevision, returns an empty slice and nil error.

type Logs

type Logs map[string][]*gitpb.Commit

Logs represents a set of Git diffs between two Checkouts.

It is a mapping of repository URLs to a list of Git commits, representing the Git log for that repository.

func ComputeLogs

func ComputeLogs(c context.Context, luciProject string, oldCheckout, newCheckout Checkout, history HistoryFunc) (Logs, error)

ComputeLogs produces a set of Git diffs between oldCheckout and newCheckout, using the repositories in the newCheckout. historyFunc is used to grab the Git history.

func (Logs) Blamelist

func (l Logs) Blamelist(template string) []EmailNotify

Blamelist computes a set of email notifications from the Logs.

func (Logs) Filter

func (l Logs) Filter(whiteset stringset.Set) Logs

Filter filters out repositories from the Logs which are not in the whitelist and returns a new Logs.

type ToNotify

type ToNotify struct {
	Notification  *notifypb.Notification
	MatchingSteps []*buildbucketpb.Step
}

ToNotify encapsulates a notification, along with the list of matching steps necessary to render templates for that notification. It's used to pass this data between the filtering/matching code and the code responsible for sending emails and updating tree status.

func Filter

func Filter(n *notifypb.Notifications, oldStatus buildbucketpb.Status, newBuild *buildbucketpb.Build) []ToNotify

Filter filters out Notification objects from Notifications by checking if we ShouldNotify based on two build statuses.

Jump to

Keyboard shortcuts

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