config

package
v0.0.0-...-71304e1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config knows how to read and parse config.yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetRegexes

func SetRegexes(js []Presubmit) error

SetRegexes compiles and validates all the regural expressions for the provided presubmits.

Types

type Agent

type Agent struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Agent watches a path and automatically loads the config stored therein.

func (*Agent) Config

func (ca *Agent) Config() *Config

Config returns the latest config. Do not modify the config.

func (*Agent) Set

func (ca *Agent) Set(c *Config)

Set sets the config. Useful for testing.

func (*Agent) Start

func (ca *Agent) Start(path string) error

Start will begin polling the config file at the path. If the first load fails, Start with return the error and abort. Future load failures will log the failure message but continue attempting to load.

type Brancher

type Brancher struct {
	// Do not run against these branches. Default is no branches.
	SkipBranches []string `json:"skip_branches"`
	// Only run against these branches. Default is all branches.
	Branches []string `json:"branches"`
}

Brancher is for shared code between jobs that only run against certain branches. An empty brancher runs against all branches.

func (Brancher) RunsAgainstAllBranch

func (br Brancher) RunsAgainstAllBranch() bool

func (Brancher) RunsAgainstBranch

func (br Brancher) RunsAgainstBranch(branch string) bool

type Config

type Config struct {
	// Full repo name (such as "kubernetes/kubernetes") -> list of jobs.
	Presubmits  map[string][]Presubmit  `json:"presubmits,omitempty"`
	Postsubmits map[string][]Postsubmit `json:"postsubmits,omitempty"`

	// Periodics are not associated with any repo.
	Periodics []Periodic `json:"periodics,omitempty"`

	Tide   Tide   `json:"tide,omitempty"`
	Plank  Plank  `json:"plank,omitempty"`
	Sinker Sinker `json:"sinker,omitempty"`

	// TODO: Move this out of the main config.
	JenkinsOperator JenkinsOperator `json:"jenkins_operator,omitempty"`

	// ProwJobNamespace is the namespace in the cluster that prow
	// components will use for looking up ProwJobs. The namespace
	// needs to exist and will not be created by prow.
	// Defaults to "default".
	ProwJobNamespace string `json:"prowjob_namespace,omitempty"`
	// PodNamespace is the namespace in the cluster that prow
	// components will use for looking up Pods owned by ProwJobs.
	// The namespace needs to exist and will not be created by prow.
	// Defaults to "default".
	PodNamespace string `json:"pod_namespace,omitempty"`

	// LogLevel enables dynamically updating the log level of the
	// standard logger that is used by all prow components.
	//
	// Valid values:
	//
	// "debug", "info", "warn", "warning", "error", "fatal", "panic"
	//
	// Defaults to "info".
	LogLevel string `json:"log_level,omitempty"`

	// PushGateway is a prometheus push gateway.
	PushGateway PushGateway `json:"push_gateway,omitempty"`
}

Config is a read-only snapshot of the config.

func Load

func Load(path string) (*Config, error)

Load loads and parses the config at path.

func (*Config) AllPeriodics

func (c *Config) AllPeriodics() []Periodic

AllPostsubmits returns all prow periodic jobs.

func (*Config) AllPostsubmits

func (c *Config) AllPostsubmits(repos []string) []Postsubmit

AllPostsubmits returns all prow postsubmit jobs in repos. if repos is empty, return all postsubmits.

func (*Config) AllPresubmits

func (c *Config) AllPresubmits(repos []string) []Presubmit

AllPresubmits returns all prow presubmit jobs in repos. if repos is empty, return all presubmits.

func (*Config) GetPresubmit

func (c *Config) GetPresubmit(repo, jobName string) *Presubmit

GetPresubmit returns the presubmit job for the provided repo and job name.

func (*Config) MatchingPresubmits

func (c *Config) MatchingPresubmits(fullRepoName, body string, testAll *regexp.Regexp) []Presubmit

func (*Config) RetestPresubmits

func (c *Config) RetestPresubmits(fullRepoName string, skipContexts, runContexts map[string]bool) []Presubmit

RetestPresubmits returns all presubmits that should be run given a /retest command. This is the set of all presubmits intersected with ((alwaysRun + runContexts) - skipContexts)

func (*Config) SetPresubmits

func (c *Config) SetPresubmits(jobs map[string][]Presubmit) error

type JenkinsOperator

type JenkinsOperator struct {
	// JobURLTemplateString compiles into JobURLTemplate at load time.
	JobURLTemplateString string `json:"job_url_template,omitempty"`
	// JobURLTemplate is compiled at load time from JobURLTemplateString. It
	// will be passed a kube.ProwJob and is used to set the URL for the
	// "details" link on GitHub as well as the link from deck.
	JobURLTemplate *template.Template `json:"-"`

	// ReportTemplateString compiles into ReportTemplate at load time.
	ReportTemplateString string `json:"report_template,omitempty"`
	// ReportTemplate is compiled at load time from ReportTemplateString. It
	// will be passed a kube.ProwJob and can provide an optional blurb below
	// the test failures comment.
	ReportTemplate *template.Template `json:"-"`

	// MaxConcurrency is the maximum number of tests running concurrently that
	// will be allowed by jenkins-operator. 0 implies no limit.
	MaxConcurrency int `json:"max_concurrency,omitempty"`

	// AllowCancellations enables aborting presubmit jobs for commits that
	// have been superseded by newer commits in Github pull requests.
	AllowCancellations bool `json:"allow_cancellations"`
}

JenkinsOperator is config for the jenkins-operator controller.

type Periodic

type Periodic struct {
	Name string `json:"name"`
	// Agent that will take care of running this job.
	Agent string `json:"agent"`
	// Kubernetes pod spec.
	Spec *kube.PodSpec `json:"spec,omitempty"`
	// Interval to wait between two runs of the job.
	Interval string   `json:"interval"`
	Tags     []string `json:"tags,omitempty"`
	// Run these jobs after successfully running this one.
	RunAfterSuccess []Periodic `json:"run_after_success"`
	// contains filtered or unexported fields
}

Periodic runs on a timer.

func (*Periodic) GetInterval

func (p *Periodic) GetInterval() time.Duration

func (*Periodic) SetInterval

func (p *Periodic) SetInterval(d time.Duration)

type Plank

type Plank struct {
	// JobURLTemplateString compiles into JobURLTemplate at load time.
	JobURLTemplateString string `json:"job_url_template,omitempty"`
	// JobURLTemplate is compiled at load time from JobURLTemplateString. It
	// will be passed a kube.ProwJob and is used to set the URL for the
	// "details" link on GitHub as well as the link from deck.
	JobURLTemplate *template.Template `json:"-"`

	// ReportTemplateString compiles into ReportTemplate at load time.
	ReportTemplateString string `json:"report_template,omitempty"`
	// ReportTemplate is compiled at load time from ReportTemplateString. It
	// will be passed a kube.ProwJob and can provide an optional blurb below
	// the test failures comment.
	ReportTemplate *template.Template `json:"-"`

	// MaxConcurrency is the maximum number of tests running concurrently that
	// will be allowed by plank. 0 implies no limit.
	MaxConcurrency int `json:"max_concurrency,omitempty"`

	// AllowCancellations enables aborting presubmit jobs for commits that
	// have been superseded by newer commits in Github pull requests.
	AllowCancellations bool `json:"allow_cancellations"`
}

Plank is config for the plank controller.

type Postsubmit

type Postsubmit struct {
	Name string `json:"name"`
	// Agent that will take care of running this job.
	Agent string `json:"agent"`
	// Kubernetes pod spec.
	Spec *kube.PodSpec `json:"spec,omitempty"`
	// Maximum number of this job running concurrently, 0 implies no limit.
	MaxConcurrency int `json:"max_concurrency"`

	Brancher
	// Run these jobs after successfully running this one.
	RunAfterSuccess []Postsubmit `json:"run_after_success"`
}

Postsubmit runs on push events.

type Presubmit

type Presubmit struct {
	// eg kubernetes-pull-build-test-e2e-gce
	Name string `json:"name"`
	// Run for every PR, or only when a comment triggers it.
	AlwaysRun bool `json:"always_run"`
	// Run if the PR modifies a file that matches this regex.
	RunIfChanged string `json:"run_if_changed"`
	// Context line for GitHub status.
	Context string `json:"context"`
	// eg @k8s-bot e2e test this
	Trigger string `json:"trigger"`
	// Valid rerun command to give users. Must match Trigger.
	RerunCommand string `json:"rerun_command"`
	// Whether or not to skip commenting and setting status on GitHub.
	SkipReport bool `json:"skip_report"`
	// Maximum number of this job running concurrently, 0 implies no limit.
	MaxConcurrency int `json:"max_concurrency"`
	// Agent that will take care of running this job.
	Agent string `json:"agent"`
	// Kubernetes pod spec.
	Spec *kube.PodSpec `json:"spec,omitempty"`
	// Run these jobs after successfully running this one.
	RunAfterSuccess []Presubmit `json:"run_after_success"`

	Brancher
	// contains filtered or unexported fields
}

Presubmit is the job-specific trigger info.

func (Presubmit) RunsAgainstChanges

func (ps Presubmit) RunsAgainstChanges(changes []string) bool

type PushGateway

type PushGateway struct {
	Endpoint string `json:"endpoint,omitempty"`
}

type Sinker

type Sinker struct {
	// ResyncPeriodString compiles into ResyncPeriod at load time.
	ResyncPeriodString string `json:"resync_period,omitempty"`
	// ResyncPeriod is how often the controller will perform a garbage
	// collection. Defaults to one hour.
	ResyncPeriod time.Duration `json:"-"`
	// MaxProwJobAgeString compiles into MaxProwJobAge at load time.
	MaxProwJobAgeString string `json:"max_prowjob_age,omitempty"`
	// MaxProwJobAge is how old a ProwJob can be before it is garbage-collected.
	// Defaults to one week.
	MaxProwJobAge time.Duration `json:"-"`
	// MaxPodAgeString compiles into MaxPodAge at load time.
	MaxPodAgeString string `json:"max_pod_age,omitempty"`
	// MaxPodAge is how old a Pod can be before it is garbage-collected.
	// Defaults to one day.
	MaxPodAge time.Duration `json:"-"`
}

Sinker is config for the sinker controller.

type Tide

type Tide struct {
	// These must be valid GitHub search queries. They should not overlap,
	// which is to say two queries should never return the same PR.
	Queries []string `json:"queries,omitempty"`
}

Tide is config for the tide pool.

Jump to

Keyboard shortcuts

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