Documentation ¶
Overview ¶
Package pjutil contains helpers for working with PlumberJobs.
Package pjutil contains helpers for working with ProwJobs.
Index ¶
- Variables
- func BatchSpec(p config.Presubmit, refs plumber.Refs) plumber.PipelineOptionsSpec
- func FilterPresubmits(filter Filter, changes config.ChangedFilesProvider, branch string, ...) ([]config.Presubmit, []config.Presubmit, error)
- func JobURL(plank config.Plank, pj plumber.PipelineOptions, log *logrus.Entry) string
- func LabelsAndAnnotationsForJob(pj plumber.PipelineOptions) (map[string]string, map[string]string)
- func LabelsAndAnnotationsForSpec(spec plumber.PipelineOptionsSpec, ...) (map[string]string, map[string]string)
- func NewPlumberJob(spec plumber.PipelineOptionsSpec, ...) plumber.PipelineOptions
- func NewPresubmit(pr *scm.PullRequest, baseSHA string, job config.Presubmit, eventGUID string) plumber.PipelineOptions
- func PeriodicSpec(p config.Periodic) plumber.PipelineOptionsSpec
- func PlumberJobFields(pj *plumber.PipelineOptions) logrus.Fields
- func PostsubmitSpec(p config.Postsubmit, refs plumber.Refs) plumber.PipelineOptionsSpec
- func PresubmitSpec(p config.Presubmit, refs plumber.Refs) plumber.PipelineOptionsSpec
- func ServePProf()
- type Filter
Constants ¶
This section is empty.
Variables ¶
var OkToTestRe = regexp.MustCompile(`(?m)^/ok-to-test\s*$`)
OkToTestRe provies the regex for `/ok-to-test`
var RetestRe = regexp.MustCompile(`(?m)^/retest\s*$`)
RetestRe provides the regex for `/retest`
var TestAllRe = regexp.MustCompile(`(?m)^/test all,?($|\s.*)`)
TestAllRe provides the regex for `/test all`
Functions ¶
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 ¶
JobURL returns the expected URL for PlumberJobStatus.
TODO(fejta): consider moving default JobURLTemplate and JobURLPrefix out of plank
func LabelsAndAnnotationsForJob ¶
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 ¶
func PeriodicSpec(p config.Periodic) plumber.PipelineOptionsSpec
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 ¶
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 ¶
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 ¶
AggregateFilter builds a filter that evaluates the child filters in order and returns the first match
func CommandFilter ¶
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 ¶
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.