pjutil

package
v0.0.428 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package pjutil contains helpers for working with PlumberJobs.

Package pjutil contains helpers for working with ProwJobs.

Index

Constants

This section is empty.

Variables

View Source
var OkToTestRe = regexp.MustCompile(`(?m)^/ok-to-test\s*$`)

OkToTestRe provies the regex for `/ok-to-test`

View Source
var RetestRe = regexp.MustCompile(`(?m)^/retest\s*$`)

RetestRe provides the regex for `/retest`

View Source
var TestAllRe = regexp.MustCompile(`(?m)^/test all,?($|\s.*)`)

TestAllRe provides the regex for `/test all`

Functions

func BatchSpec

BatchSpec initializes a PipelineOptionsSpec for a given batch job and ref spec.

func FilterPresubmits

func FilterPresubmits(filter Filter, changes config.ChangedFilesProvider, branch string, presubmits []config.Presubmit, logger *logrus.Entry) ([]config.Presubmit, []config.Presubmit, error)

FilterPresubmits determines which presubmits should run and which should be skipped by evaluating the user-provided filter.

func JobURL

func JobURL(plank config.Plank, pj plumber.PipelineOptions, log *logrus.Entry) string

JobURL returns the expected URL for PlumberJobStatus.

TODO(fejta): consider moving default JobURLTemplate and JobURLPrefix out of plank

func LabelsAndAnnotationsForJob

func LabelsAndAnnotationsForJob(pj plumber.PipelineOptions) (map[string]string, map[string]string)

LabelsAndAnnotationsForJob returns a standard set of labels to add to pod/build/etc resources.

func LabelsAndAnnotationsForSpec

func LabelsAndAnnotationsForSpec(spec plumber.PipelineOptionsSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string)

LabelsAndAnnotationsForSpec returns a minimal set of labels to add to plumberJobs or its owned resources.

User-provided extraLabels and extraAnnotations values will take precedence over auto-provided values.

func NewPlumberJob

func NewPlumberJob(spec plumber.PipelineOptionsSpec, extraLabels, extraAnnotations map[string]string) plumber.PipelineOptions

NewPlumberJob initializes a PipelineOptions out of a PipelineOptionsSpec.

func NewPresubmit

func NewPresubmit(pr *scm.PullRequest, baseSHA string, job config.Presubmit, eventGUID string) plumber.PipelineOptions

NewPresubmit converts a config.Presubmit into a builder.PipelineOptions. The builder.Refs are configured correctly per the pr, baseSHA. The eventGUID becomes a gitprovider.EventGUID label.

func PeriodicSpec

PeriodicSpec initializes a PipelineOptionsSpec for a given periodic job.

func PlumberJobFields

func PlumberJobFields(pj *plumber.PipelineOptions) logrus.Fields

PlumberJobFields extracts logrus fields from a plumberJob useful for logging.

func PostsubmitSpec

func PostsubmitSpec(p config.Postsubmit, refs plumber.Refs) plumber.PipelineOptionsSpec

PostsubmitSpec initializes a PipelineOptionsSpec for a given postsubmit job.

func PresubmitSpec

func PresubmitSpec(p config.Presubmit, refs plumber.Refs) plumber.PipelineOptionsSpec

PresubmitSpec initializes a PipelineOptionsSpec for a given presubmit job.

func ServePProf

func ServePProf()

ServePProf sets up a handler for pprof debug endpoints and starts a server for them asynchronously. The contents of this function are identical to what the `net/http/pprof` package does on import for the simple case where the default mux is to be used, but with a custom mux to ensure we don't serve this data from an exposed port.

Types

type Filter

type Filter func(p config.Presubmit) (shouldRun bool, forcedToRun bool, defaultBehavior bool)

Filter digests a presubmit config to determine if:

  • we the presubmit matched the filter
  • we know that the presubmit is forced to run
  • what the default behavior should be if the presubmit runs conditionally and does not match trigger conditions

func AggregateFilter

func AggregateFilter(filters []Filter) Filter

AggregateFilter builds a filter that evaluates the child filters in order and returns the first match

func CommandFilter

func CommandFilter(body string) Filter

CommandFilter builds a filter for `/test foo`

func PresubmitFilter

func PresubmitFilter(honorOkToTest bool, contextGetter contextGetter, body string, logger *logrus.Entry) (Filter, error)

PresubmitFilter creates a filter for presubmits

func RetestFilter

func RetestFilter(failedContexts, allContexts sets.String) Filter

RetestFilter builds a filter for `/retest`

func TestAllFilter

func TestAllFilter() Filter

TestAllFilter builds a filter for the automatic behavior of `/test all`. Pipelines that explicitly match `/test all` in their trigger regex will be handled by a commandFilter for the comment in question.

Jump to

Keyboard shortcuts

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