plumber

package
v0.0.524 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TektonAgent the default agent name
	TektonAgent = "tekton"
	// PlumberJobTypeLabel is added in resources created by lighthouse and
	// carries the job type (presubmit, postsubmit, periodic, batch)
	// that the pod is running.
	PlumberJobTypeLabel = "lighthouse.jenkins-x.io/type"
	// PlumberJobIDLabel is added in resources created by lighthouse and
	// carries the ID of the PipelineOptions that the pod is fulfilling.
	// We also name resources after the PipelineOptions that spawned them but
	// this allows for multiple resources to be linked to one
	// PipelineOptions.
	PlumberJobIDLabel = "lighthouse.jenkins-x.io/id"
	// PlumberJobAnnotation is added in resources created by lighthouse and
	// carries the name of the job that the pod is running. Since
	// job names can be arbitrarily long, this is added as
	// an annotation instead of a label.
	PlumberJobAnnotation = "lighthouse.jenkins-x.io/job"
)
View Source
const (
	// JobSpecEnv is a legacy Prow variable with "type:(type)"
	JobSpecEnv = "JOB_SPEC"
	// JobNameEnv is the name of the job
	JobNameEnv = "JOB_NAME"
	// JobTypeEnv is the type of job
	JobTypeEnv = "JOB_TYPE"
	// RepoOwnerEnv is the org/owner for the repository we're building
	RepoOwnerEnv = "REPO_OWNER"
	// RepoNameEnv is the name of the repository we're building
	RepoNameEnv = "REPO_NAME"
	// PullBaseRefEnv is the base ref (such as master) for a pull request
	PullBaseRefEnv = "PULL_BASE_REF"
	// PullBaseShaEnv is the actual commit sha for the base for a pull request
	PullBaseShaEnv = "PULL_BASE_SHA"
	// PullRefsEnv is the refs and shas for the base and PR, like "master:abcd1234...,123:5678abcd..." for PR-123.
	PullRefsEnv = "PULL_REFS"
	// PullNumberEnv is the pull request number
	PullNumberEnv = "PULL_NUMBER"
	// PullPullShaEnv is the pull request's sha
	PullPullShaEnv = "PULL_PULL_SHA"
)

Environment variables to be added to the pipeline we kick off

Variables

This section is empty.

Functions

func NewMetaPipelineClient

func NewMetaPipelineClient(factory jxfactory.Factory) (metapipeline.Client, error)

NewMetaPipelineClient creates a new client for the creation and application of meta pipelines. The responsibility of the meta pipeline is to prepare the execution pipeline and to allow Apps to contribute the this execution pipeline.

Types

type ByNum

type ByNum []Pull

ByNum implements sort.Interface for []Pull to sort by ascending PR number.

func (ByNum) Len

func (prs ByNum) Len() int

func (ByNum) Less

func (prs ByNum) Less(i, j int) bool

func (ByNum) Swap

func (prs ByNum) Swap(i, j int)

type DecorationConfig

type DecorationConfig struct {
	// Timeout is how long the pod utilities will wait
	// before aborting a job with SIGINT.
	Timeout *Duration `json:"timeout,omitempty"`
	// GracePeriod is how long the pod utilities will wait
	// after sending SIGINT to send SIGKILL when aborting
	// a job. Only applicable if decorating the PodSpec.
	GracePeriod *Duration `json:"grace_period,omitempty"`

	/*
		// UtilityImages holds pull specs for utility container
		// images used to decorate a PodSpec.
		UtilityImages *UtilityImages `json:"utility_images,omitempty"`
		// GCSConfiguration holds options for pushing logs and
		// artifacts to GCS from a job.
		GCSConfiguration *GCSConfiguration `json:"gcs_configuration,omitempty"`
	*/
	// GCSCredentialsSecret is the name of the Kubernetes secret
	// that holds GCS push credentials.
	GCSCredentialsSecret string `json:"gcs_credentials_secret,omitempty"`
	// SSHKeySecrets are the names of Kubernetes secrets that contain
	// SSK keys which should be used during the cloning process.
	SSHKeySecrets []string `json:"ssh_key_secrets,omitempty"`
	// SSHHostFingerprints are the fingerprints of known SSH hosts
	// that the cloning process can trust.
	// Create with ssh-keyscan [-t rsa] host
	SSHHostFingerprints []string `json:"ssh_host_fingerprints,omitempty"`
	// SkipCloning determines if we should clone source code in the
	// initcontainers for jobs that specify refs
	SkipCloning *bool `json:"skip_cloning,omitempty"`
	// CookieFileSecret is the name of a kubernetes secret that contains
	// a git http.cookiefile, which should be used during the cloning process.
	CookiefileSecret string `json:"cookiefile_secret,omitempty"`
}

DecorationConfig specifies how to augment pods.

This is primarily used to provide automatic integration with gubernator and testgrid.

func (*DecorationConfig) Validate

func (d *DecorationConfig) Validate() error

Validate ensures all the values set in the DecorationConfig are valid.

type Duration

type Duration struct {
	Duration time.Duration
}

Duration is a wrapper around time.Duration that parses times in either 'integer number of nanoseconds' or 'duration string' formats and serializes to 'duration string' format.

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON marshals a duration object to a byte array

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a byte array into a Duration object

type PipelineBuilder

type PipelineBuilder struct {
	// contains filtered or unexported fields
}

PipelineBuilder default builder

func (*PipelineBuilder) Create

func (b *PipelineBuilder) Create(request *PipelineOptions, metapipelineClient metapipeline.Client, repository scm.Repository) (*PipelineOptions, error)

Create creates a pipeline

func (*PipelineBuilder) List

List list current pipelines

type PipelineKind

type PipelineKind string

PipelineKind specifies how the job is triggered.

const (
	// PresubmitJob means it runs on unmerged PRs.
	PresubmitJob PipelineKind = "presubmit"
	// PostsubmitJob means it runs on each new commit.
	PostsubmitJob PipelineKind = "postsubmit"
	// Periodic job means it runs on a time-basis, unrelated to git changes.
	PeriodicJob PipelineKind = "periodic"
	// BatchJob tests multiple unmerged PRs at the same time.
	BatchJob PipelineKind = "batch"
)

Various job types.

type PipelineOptions

type PipelineOptions struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   PipelineOptionsSpec `json:"spec,omitempty"`
	Status PipelineStatus      `json:"status,omitempty"`
}

PipelineOptions contains the arguments to pass to the Plumber to create a Tekton Pipeline

func ToPipelineOptions

func ToPipelineOptions(activity *v1.PipelineActivity) PipelineOptions

ToPipelineOptions converts the PipelineActivity to a PipelineOptions object

type PipelineOptionsList

type PipelineOptionsList struct {
	Items []PipelineOptions
}

PipelineOptionsList represents a list of pipeline options

type PipelineOptionsSpec

type PipelineOptionsSpec struct {
	// Type is the type of job and informs how
	// the jobs is triggered
	Type PipelineKind `json:"type,omitempty"`
	// Namespace defines where to create pods/resources.
	Namespace string `json:"namespace,omitempty"`
	// Job is the name of the job
	Job string `json:"job,omitempty"`
	// Refs is the code under test, determined at
	// runtime by Prow itself
	Refs *Refs `json:"refs,omitempty"`
	// Context is the name of the status context used to
	// report back to GitHub
	Context string `json:"context,omitempty"`
	// RerunCommand is the command a user would write to
	// trigger this job on their pull request
	RerunCommand string `json:"rerun_command,omitempty"`
	// MaxConcurrency restricts the total number of instances
	// of this job that can run in parallel at once
	MaxConcurrency int `json:"max_concurrency,omitempty"`
	// LastCommitSHA is the commit that will be/has been reported to on the SCM provider
	LastCommitSHA string `json:"lastCommitSHA,omitempty"`
}

PipelineOptionsSpec the spec of a pipeline request

func (*PipelineOptionsSpec) GetEnvVars added in v0.0.456

func (s *PipelineOptionsSpec) GetEnvVars() map[string]string

GetEnvVars gets a map of the environment variables we'll set in the pipeline for this spec.

type PipelineState

type PipelineState string

PipelineState specifies the current pipelne status

const (
	// TriggeredState for pipelines that have been triggered
	TriggeredState PipelineState = "triggered"

	// PendingState pipeline is pending
	PendingState PipelineState = "pending"

	// RunningState pipeline is running
	RunningState PipelineState = "running"

	// SuccessState pipeline is successful
	SuccessState PipelineState = "success"

	// FailureState failed
	FailureState PipelineState = "failure"

	// AbortedState aborted
	AbortedState PipelineState = "aborted"
)

Various job types.

func ToPipelineState

func ToPipelineState(status v1.ActivityStatusType) PipelineState

ToPipelineState converts the PipelineActivity state to plumber state

type PipelineStatus

type PipelineStatus struct {
	State PipelineState `json:"state,omitempty"`
}

PipelineStatus represents the status of a pipeline

type Plumber

type Plumber interface {
	// Create creates new tekton pipelines
	Create(*PipelineOptions, metapipeline.Client, scm.Repository) (*PipelineOptions, error)

	// lists the status of previously created tekton pipelines
	List(opts metav1.ListOptions) (*PipelineOptionsList, error)
}

Plumber the interface is the service which creates Pipelines

func NewPlumber

func NewPlumber(jxClient jxclient.Interface, namespace string) (Plumber, error)

NewPlumber creates a new builder

type Pull

type Pull struct {
	Number int    `json:"number"`
	Author string `json:"author"`
	SHA    string `json:"sha"`
	Title  string `json:"title,omitempty"`

	// Ref is git ref can be checked out for a change
	// for example,
	// github: pull/123/head
	// gerrit: refs/changes/00/123/1
	Ref string `json:"ref,omitempty"`
	// Link links to the pull request itself.
	Link string `json:"link,omitempty"`
	// CommitLink links to the commit identified by the SHA.
	CommitLink string `json:"commit_link,omitempty"`
	// AuthorLink links to the author of the pull request.
	AuthorLink string `json:"author_link,omitempty"`
}

Pull describes a pull request at a particular point in time.

type Refs

type Refs struct {
	// Org is something like kubernetes or k8s.io
	Org string `json:"org"`
	// Repo is something like test-infra
	Repo string `json:"repo"`
	// RepoLink links to the source for Repo.
	RepoLink string `json:"repo_link,omitempty"`

	BaseRef string `json:"base_ref,omitempty"`
	BaseSHA string `json:"base_sha,omitempty"`
	// BaseLink is a link to the commit identified by BaseSHA.
	BaseLink string `json:"base_link,omitempty"`

	Pulls []Pull `json:"pulls,omitempty"`

	// PathAlias is the location under <root-dir>/src
	// where this repository is cloned. If this is not
	// set, <root-dir>/src/github.com/org/repo will be
	// used as the default.
	PathAlias string `json:"path_alias,omitempty"`
	// CloneURI is the URI that is used to clone the
	// repository. If unset, will default to
	// `https://github.com/org/repo.git`.
	CloneURI string `json:"clone_uri,omitempty"`
	// SkipSubmodules determines if submodules should be
	// cloned when the job is run. Defaults to true.
	SkipSubmodules bool `json:"skip_submodules,omitempty"`
	// CloneDepth is the depth of the clone that will be used.
	// A depth of zero will do a full clone.
	CloneDepth int `json:"clone_depth,omitempty"`
}

Refs describes how the repo was constructed.

func (*Refs) String

func (r *Refs) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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