jx: github.com/jenkins-x/jx/pkg/tekton Index | Files | Directories

package tekton

import "github.com/jenkins-x/jx/pkg/tekton"


Package Files

constants.go crds.go pipeline_info.go pipelines.go pullrefs.go


const (
    // LastBuildNumberAnnotationPrefix used to annotate SourceRepository with the latest build number for a branch
    LastBuildNumberAnnotationPrefix = "jenkins.io/last-build-number-for-"

    // LabelOwner is the label added to Tekton CRDs for the owner of the repository being built.
    LabelOwner = v1.LabelOwner

    // LabelRepo is the label added to Tekton CRDs for the repository being built.
    LabelRepo = v1.LabelRepository

    // LabelBranch is the label added to Tekton CRDs for the branch being built.
    LabelBranch = v1.LabelBranch

    // LabelBuild is the label added to Tekton CRDs for the build number.
    LabelBuild = v1.LabelBuild

    // LabelContext is the label added to Tekton CRDs for the context being built.
    LabelContext = "context"

    // LabelType is the label added to Tekton CRDs for the type of pipeline.
    LabelType = "jenkins.io/pipelineType"

    // DefaultPipelineSA is the default service account used for pipelines
    DefaultPipelineSA = "tekton-bot"

func ApplyPipeline Uses

func ApplyPipeline(jxClient versioned.Interface, kubeClient kubernetes.Interface, tektonClient tektonclient.Interface, crds *CRDWrapper, ns string, activityKey *kube.PromoteStepActivityKey) error

ApplyPipeline applies the tasks and pipeline to the cluster and creates and applies a PipelineResource for their source repo and a pipelineRun to execute them.

func ApplyPipelineRun Uses

func ApplyPipelineRun(tektonClient tektonclient.Interface, ns string, run *v1alpha1.PipelineRun) (*v1alpha1.PipelineRun, error)

ApplyPipelineRun lazily creates a Tekton PipelineRun.

func CancelPipelineRun Uses

func CancelPipelineRun(tektonClient tektonclient.Interface, ns string, pr *pipelineapi.PipelineRun) error

CancelPipelineRun cancels a Pipeline

func CreateOrUpdatePipeline Uses

func CreateOrUpdatePipeline(tektonClient tektonclient.Interface, ns string, created *v1alpha1.Pipeline) (*v1alpha1.Pipeline, error)

CreateOrUpdatePipeline lazily creates a Tekton Pipeline for the given git repository, branch and context

func CreateOrUpdateSourceResource Uses

func CreateOrUpdateSourceResource(tektonClient tektonclient.Interface, ns string, created *v1alpha1.PipelineResource) (*v1alpha1.PipelineResource, error)

CreateOrUpdateSourceResource lazily creates a Tekton Pipeline PipelineResource for the given git repository

func CreateOrUpdateTask Uses

func CreateOrUpdateTask(tektonClient tektonclient.Interface, ns string, created *v1alpha1.Task) (*v1alpha1.Task, error)

CreateOrUpdateTask lazily creates a Tekton Pipeline Task

func CreatePipelineRun Uses

func CreatePipelineRun(resources []*pipelineapi.PipelineResource,
    name string,
    apiVersion string,
    labels map[string]string,
    serviceAccount string,
    pipelineParams []pipelineapi.Param,
    timeout *metav1.Duration,
    affinity *corev1.Affinity,
    tolerations []corev1.Toleration) *pipelineapi.PipelineRun

CreatePipelineRun creates the PipelineRun struct.

func GenerateNextBuildNumber Uses

func GenerateNextBuildNumber(tektonClient tektonclient.Interface, jxClient jxClient.Interface, ns string, gitInfo *gits.GitRepository, branch string, duration time.Duration, context string, useActivity bool) (string, error)

GenerateNextBuildNumber generates a new build number for the given project.

func GeneratePipelineActivity Uses

func GeneratePipelineActivity(buildNumber string, branch string, gitInfo *gits.GitRepository, context string, pr *PullRefs) *kube.PromoteStepActivityKey

GeneratePipelineActivity generates a initial PipelineActivity CRD so UI/get act can get an earlier notification that the jobs have been scheduled

func GenerateSourceRepoResource Uses

func GenerateSourceRepoResource(name string, gitInfo *gits.GitRepository, revision string) *pipelineapi.PipelineResource

GenerateSourceRepoResource generates the PipelineResource for the git repository we are operating on.

func PipelineResourceName Uses

func PipelineResourceName(organisation string, name string, branch string, context string, pipelineType string) string

PipelineResourceName returns the pipeline resource name for the given git org, repo name, branch and context. It will always be unique.

func PipelineResourceNameFromGitInfo Uses

func PipelineResourceNameFromGitInfo(gitInfo *gits.GitRepository, branch string, context string, pipelineType string) string

PipelineResourceNameFromGitInfo returns the pipeline resource name for the given git repository, branch and context

func PipelineRunIsComplete Uses

func PipelineRunIsComplete(pr *pipelineapi.PipelineRun) bool

PipelineRunIsComplete returns true if the PipelineRun has completed or has running steps.

func PipelineRunIsNotPending Uses

func PipelineRunIsNotPending(pr *pipelineapi.PipelineRun) bool

PipelineRunIsNotPending returns true if the PipelineRun has completed or has running steps.

func SortPipelineRunInfos Uses

func SortPipelineRunInfos(pris []*PipelineRunInfo)

SortPipelineRunInfos sorts a slice of PipelineRunInfos by their org, repo, branch, and build number

func StructureForPipelineRun Uses

func StructureForPipelineRun(jxClient versioned.Interface, ns string, run *pipelineapi.PipelineRun) (*v1.PipelineStructure, error)

StructureForPipelineRun finds the PipelineStructure for the given PipelineRun, trying its name first and then its Pipeline name, returning an error if no PipelineStructure can be found.

type CRDWrapper Uses

type CRDWrapper struct {
    // contains filtered or unexported fields

CRDWrapper is a wrapper around the various Tekton CRDs

func NewCRDWrapper Uses

func NewCRDWrapper(pipeline *pipelineapi.Pipeline,
    tasks []*pipelineapi.Task,
    resources []*pipelineapi.PipelineResource,
    structure *v1.PipelineStructure,
    run *pipelineapi.PipelineRun) (*CRDWrapper, error)

NewCRDWrapper creates a new wrapper for all required Tekton CRDs.

func (*CRDWrapper) AddLabels Uses

func (crds *CRDWrapper) AddLabels(labels map[string]string)

AddLabels merges the specified labels into the PipelineRun labels.

func (*CRDWrapper) Name Uses

func (crds *CRDWrapper) Name() string

Name returns the name of the Pipeline.

func (*CRDWrapper) ObjectReferences Uses

func (crds *CRDWrapper) ObjectReferences() []kube.ObjectReference

ObjectReferences creates the generic Kube resource metadata.

func (*CRDWrapper) Pipeline Uses

func (crds *CRDWrapper) Pipeline() *pipelineapi.Pipeline

Pipeline returns a pointer to the Tekton Pipeline.

func (*CRDWrapper) PipelineRun Uses

func (crds *CRDWrapper) PipelineRun() *pipelineapi.PipelineRun

PipelineRun returns a pointers to Tekton PipelineRun.

func (*CRDWrapper) Resources Uses

func (crds *CRDWrapper) Resources() []*pipelineapi.PipelineResource

Resources returns an array of pointers to Tekton PipelineResource.

func (*CRDWrapper) String Uses

func (crds *CRDWrapper) String() string

func (*CRDWrapper) Structure Uses

func (crds *CRDWrapper) Structure() *v1.PipelineStructure

Structure returns a pointers to Tekton PipelineStructure.

func (*CRDWrapper) Tasks Uses

func (crds *CRDWrapper) Tasks() []*pipelineapi.Task

Tasks returns an array of pointers to Tekton Tasks.

func (*CRDWrapper) WriteToDisk Uses

func (crds *CRDWrapper) WriteToDisk(dir string, pipelineActivity *kube.PromoteStepActivityKey) error

WriteToDisk writes the Tekton CRDs to disk. All CRDs are created in the specified directory. One YAML file per CRD.

type PipelineRunInfo Uses

type PipelineRunInfo struct {
    Name              string
    Organisation      string
    Repository        string
    Branch            string
    Context           string
    Build             string
    BuildNumber       int
    Pipeline          string
    PipelineRun       string
    LastCommitSHA     string
    BaseSHA           string
    LastCommitMessage string
    LastCommitURL     string
    GitURL            string
    GitInfo           *gits.GitRepository
    Stages            []*StageInfo
    Type              string
    CreatedTime       time.Time

PipelineRunInfo provides information on a PipelineRun and its stages for use in getting logs and populating activity

func CreatePipelineRunInfo Uses

func CreatePipelineRunInfo(prName string, podList *corev1.PodList, ps *v1.PipelineStructure, pr *tektonv1alpha1.PipelineRun) (*PipelineRunInfo, error)

CreatePipelineRunInfo looks up the PipelineRun for a given name and creates the PipelineRunInfo for it

func (*PipelineRunInfo) FindFirstStagePod Uses

func (pri *PipelineRunInfo) FindFirstStagePod() *corev1.Pod

FindFirstStagePod finds the first stage in this pipeline run to have a pod, and then returns its pod

func (PipelineRunInfo) GetBuild Uses

func (pri PipelineRunInfo) GetBuild() string

GetBuild gets the build identifier

func (*PipelineRunInfo) GetOrderedTaskStages Uses

func (pri *PipelineRunInfo) GetOrderedTaskStages() []*StageInfo

GetOrderedTaskStages gets all the stages in this pipeline which actually contain a Task, in rough execution order TODO: Handle parallelism better, where execution is not a straight line.

func (*PipelineRunInfo) MatchesPipeline Uses

func (pri *PipelineRunInfo) MatchesPipeline(activity *v1.PipelineActivity) bool

MatchesPipeline returns true if this build info matches the given pipeline

func (*PipelineRunInfo) SetPodsForPipelineRun Uses

func (pri *PipelineRunInfo) SetPodsForPipelineRun(podList *corev1.PodList, ps *v1.PipelineStructure) error

SetPodsForPipelineRun populates the pods for all stages within its PipelineRunInfo

func (*PipelineRunInfo) Status Uses

func (pri *PipelineRunInfo) Status() string

Status returns the build status

func (PipelineRunInfo) ToBuildPodInfo Uses

func (pri PipelineRunInfo) ToBuildPodInfo() *builds.BuildPodInfo

ToBuildPodInfo converts the object into a BuildPodInfo so it can be easily filtered

type PipelineRunInfoFilter Uses

type PipelineRunInfoFilter struct {
    Owner      string
    Repository string
    Branch     string
    Build      string
    Filter     string
    Pending    bool
    Context    string

PipelineRunInfoFilter allows specifying criteria on which to filter a list of PipelineRunInfos

func (*PipelineRunInfoFilter) BuildNumber Uses

func (o *PipelineRunInfoFilter) BuildNumber() int

BuildNumber returns the integer build number filter if specified

func (*PipelineRunInfoFilter) PipelineRunMatches Uses

func (o *PipelineRunInfoFilter) PipelineRunMatches(info *PipelineRunInfo) bool

PipelineRunMatches returns true if the pipeline run info matches the filter

type PipelineRunInfoOrder Uses

type PipelineRunInfoOrder []*PipelineRunInfo

PipelineRunInfoOrder allows sorting of a slice of PipelineRunInfos

func (PipelineRunInfoOrder) Len Uses

func (a PipelineRunInfoOrder) Len() int

func (PipelineRunInfoOrder) Less Uses

func (a PipelineRunInfoOrder) Less(i, j int) bool

func (PipelineRunInfoOrder) Swap Uses

func (a PipelineRunInfoOrder) Swap(i, j int)

type PipelineType Uses

type PipelineType int

PipelineType is used to differentiate between actual build pipelines and pipelines to create the build pipelines, aka meta pipelines.

const (
    // BuildPipeline is the yype for the actual build pipeline
    BuildPipeline PipelineType = iota

    // MetaPipeline type for the meta pipeline used to generate the build pipeline

func (PipelineType) String Uses

func (s PipelineType) String() string

type PullRefs Uses

type PullRefs struct {
    BaseBranch string
    BaseSha    string
    ToMerge    map[string]string

PullRefs is the result of parsing the Prow PULL_REFS

func ParsePullRefs Uses

func ParsePullRefs(pullRefs string) (*PullRefs, error)

ParsePullRefs parses the Prow PULL_REFS env var formatted string and converts to a map of branch:sha

func (*PullRefs) String Uses

func (pr *PullRefs) String() string

type StageInfo Uses

type StageInfo struct {
    // TODO: For now, we're not including git info - we're going to assume we have the same git info for the whole
    // pipeline.
    Name string

    // These fields will populated for all non-parent stages
    PodName        string
    Task           string
    TaskRun        string
    FirstStepImage string
    CreatedTime    time.Time
    Pod            *corev1.Pod

    // These fields will only be populated for appropriate parent stages
    Parallel []*StageInfo
    Stages   []*StageInfo

    // This field will be non-empty if this is a nested stage, containing a list of  the names of all its parent stages with the top-level parent first
    Parents []string

StageInfo provides information on a particular stage, including its pod info or info on its nested stages

func (*StageInfo) GetFullChildStageNames Uses

func (si *StageInfo) GetFullChildStageNames(includeSelf bool) []string

GetFullChildStageNames gets the fully qualified (i.e., with parents appended) names of each stage underneath this one.

func (*StageInfo) GetStageNameIncludingParents Uses

func (si *StageInfo) GetStageNameIncludingParents() string

GetStageNameIncludingParents constructs a full stage name including its parents, if they exist.

func (*StageInfo) SetPodsForStageInfo Uses

func (si *StageInfo) SetPodsForStageInfo(podList *corev1.PodList, prName string) error

SetPodsForStageInfo populates the pods for a particular stage and/or its children



Package tekton imports 37 packages (graph). Updated 2020-08-05. Refresh now. Tools for package owners.