jobutil

package
v0.0.774 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Package jobutil contains helpers for working with LighthouseJobs.

Package jobutil contains helpers for working with ProwJobs.

Index

Constants

This section is empty.

Variables

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

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

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

RetestRe provides the regex for `/retest`

View Source
var TestAllRe = regexp.MustCompile(`(?m)^/(?:lh-)?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 job.ChangedFilesProvider, branch string, presubmits []job.Presubmit, logger *logrus.Entry) ([]job.Presubmit, []job.Presubmit, error)

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

func LabelsAndAnnotationsForJob

func LabelsAndAnnotationsForJob(lj v1alpha1.LighthouseJob, buildID string) (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 v1alpha1.LighthouseJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string)

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

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

func LighthouseJobFields

func LighthouseJobFields(pj *v1alpha1.LighthouseJob) logrus.Fields

LighthouseJobFields extracts logrus fields from a LighthouseJob useful for logging.

func NewLighthouseJob

func NewLighthouseJob(spec v1alpha1.LighthouseJobSpec, extraLabels, extraAnnotations map[string]string) v1alpha1.LighthouseJob

NewLighthouseJob initializes a LighthouseJob out of a LighthouseJobSpec.

func NewPresubmit

func NewPresubmit(pr *scm.PullRequest, baseSHA string, job job.Presubmit, eventGUID string, prRefFmt string) v1alpha1.LighthouseJob

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 job.Periodic) v1alpha1.LighthouseJobSpec

PeriodicSpec initializes a PipelineOptionsSpec for a given periodic job.

func PostsubmitSpec

func PostsubmitSpec(p job.Postsubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec

PostsubmitSpec initializes a PipelineOptionsSpec for a given postsubmit job.

func PresubmitSpec

func PresubmitSpec(p job.Presubmit, refs v1alpha1.Refs) v1alpha1.LighthouseJobSpec

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 job.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