tekton

package
v0.0.0-...-392d2aa Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// master branch in github/gitlab
	MasterBranch = "master"

	// main branch in github/gitlab
	MainBranch = "main"

	// PipelineAsCodeSourceBranchAnnotation is the branch name of the the pull request is created from
	PipelineAsCodeSourceBranchAnnotation = "pipelinesascode.tekton.dev/source-branch"

	// PipelineAsCodeSourceRepoOrg is the repo org build PLR is triggered by
	PipelineAsCodeSourceRepoOrg = "pipelinesascode.tekton.dev/url-org"

	// PipelineAsCodePullRequestLabel is the type of event which triggered the pipelinerun in build service
	PipelineAsCodePullRequestLabel = "pipelinesascode.tekton.dev/pull-request"
)
View Source
const (
	// PipelinesLabelPrefix is the prefix of the pipelines label
	PipelinesLabelPrefix = "pipelines.appstudio.openshift.io"

	// TestLabelPrefix contains the prefix applied to labels and annotations related to testing.
	TestLabelPrefix = "test.appstudio.openshift.io"

	// PipelinesAsCodePrefix contains the prefix applied to labels and annotations copied from Pipelines as Code resources.
	PipelinesAsCodePrefix = "pac.test.appstudio.openshift.io"

	// BuildPipelineRunPrefix contains the build pipeline run related labels and annotations
	BuildPipelineRunPrefix = "build.appstudio"

	// CustomLabelPrefix contains the prefix applied to custom user-defined labels and annotations.
	CustomLabelPrefix = "custom.appstudio.openshift.io"

	// resource labels for snapshot, application and component
	ResourceLabelSuffix = "appstudio.openshift.io"

	// PipelineTypeTest is the type for PipelineRuns created to run an integration Pipeline
	PipelineTypeTest = "test"

	// Name of tekton resolver for git
	TektonResolverGit = "git"

	// Name of tekton git resolver param url
	TektonResolverGitParamURL = "url"

	// Name of tekton git resolver param revision
	TektonResolverGitParamRevision = "revision"
)
View Source
const (
	// PipelineRunTypeLabel contains the type of the PipelineRunTypeLabel.
	PipelineRunTypeLabel = "pipelines.appstudio.openshift.io/type"

	// PipelineRunBuildType is the type denoting a build PipelineRun.
	PipelineRunBuildType = "build"

	// PipelineRunTestType is the type denoting a test PipelineRun.
	PipelineRunTestType = "test"

	// PipelineRunComponentLabel is the label denoting the application.
	PipelineRunComponentLabel = "appstudio.openshift.io/component"

	// PipelineRunApplicationLabel is the label denoting the application.
	PipelineRunApplicationLabel = "appstudio.openshift.io/application"

	// PipelineRunChainsSignedAnnotation is the label added by Tekton Chains to signed PipelineRuns
	PipelineRunChainsSignedAnnotation = "chains.tekton.dev/signed"

	// PipelineRunImageUrlParamName name of image url output param
	PipelineRunImageUrlParamName = "IMAGE_URL"

	// PipelineRunImageDigestParamName name of image digest in PipelineRun result param
	PipelineRunImageDigestParamName = "IMAGE_DIGEST"

	// PipelineRunChainsGitUrlParamName name of param chains repo url
	PipelineRunChainsGitUrlParamName = "CHAINS-GIT_URL"

	// PipelineRunChainsGitCommitParamName name of param repo chains commit
	PipelineRunChainsGitCommitParamName = "CHAINS-GIT_COMMIT"
)

Variables

View Source
var (
	// PipelinesTypeLabel is the label used to describe the type of pipeline
	PipelinesTypeLabel = fmt.Sprintf("%s/%s", PipelinesLabelPrefix, "type")

	// TestNameLabel is the label used to specify the name of the Test associated with the PipelineRun
	TestNameLabel = fmt.Sprintf("%s/%s", TestLabelPrefix, "name")

	// ScenarioNameLabel is the label used to specify the name of the IntegrationTestScenario associated with the PipelineRun
	ScenarioNameLabel = fmt.Sprintf("%s/%s", TestLabelPrefix, "scenario")

	// SnapshotNameLabel is the label of specific the name of the snapshot associated with PipelineRun
	SnapshotNameLabel = fmt.Sprintf("%s/%s", ResourceLabelSuffix, "snapshot")

	// EnvironmentNameLabel is the label of specific the name of the environment associated with PipelineRun
	EnvironmentNameLabel = fmt.Sprintf("%s/%s", ResourceLabelSuffix, "environment")

	// ApplicationNameLabel is the label of specific the name of the Application associated with PipelineRun
	ApplicationNameLabel = fmt.Sprintf("%s/%s", ResourceLabelSuffix, "application")

	// ComponentNameLabel is the label of specific the name of the component associated with PipelineRun
	ComponentNameLabel = fmt.Sprintf("%s/%s", ResourceLabelSuffix, "component")

	// OptionalLabel is the label used to specify if an IntegrationTestScenario is allowed to fail
	OptionalLabel = fmt.Sprintf("%s/%s", TestLabelPrefix, "optional")
)

Functions

func AnnotateBuildPipelineRun

func AnnotateBuildPipelineRun(ctx context.Context, pipelineRun *tektonv1.PipelineRun, key, value string, cl client.Client) error

AnnotateBuildPipelineRun sets annotation for a build pipelineRun in defined context and returns that pipeline

func AnnotateBuildPipelineRunWithCreateSnapshotAnnotation

func AnnotateBuildPipelineRunWithCreateSnapshotAnnotation(ctx context.Context, pipelineRun *tektonv1.PipelineRun, cl client.Client, ensureSnapshotExistsErr error) error

AnnotateBuildPipelineRunWithCreateSnapshotAnnotation sets annotation test.appstudio.openshift.io/create-snapshot-status to build pipelineRun with a message that reflects either success or failure for creating a snapshot

func BuildPipelineRunCreatedPredicate

func BuildPipelineRunCreatedPredicate() predicate.Predicate

BuildPipelineRunCreatedPredicate returns a predicate which filters out all objects except Build PipelineRuns which have been created

func BuildPipelineRunDeletingPredicate

func BuildPipelineRunDeletingPredicate() predicate.Predicate

BuildPipelineRunDeletingPredicate returns a predicate which filters out all objects except Build PipelineRuns which have been updated to deleting

func BuildPipelineRunFailedPredicate

func BuildPipelineRunFailedPredicate() predicate.Predicate

BuildPipelineRunFailedPredicate returns a predicate which filters out all objects except Build PipelineRuns which have finished and have failed.

func BuildPipelineRunSignedAndSucceededPredicate

func BuildPipelineRunSignedAndSucceededPredicate() predicate.Predicate

BuildPipelineRunSignedAndSucceededPredicate returns a predicate which filters out all objects except Build PipelineRuns which have finished, been signed and haven't had a Snapshot created for them.

func GenerateSHA

func GenerateSHA(str string) string

GenerateSHA generate a 63 charactors sha string used by pipelineRun and snapshot label

func GetComponentSourceGitCommit

func GetComponentSourceGitCommit(object client.Object) (string, error)

GetComponentSourceGitCommit returns a string containing the CHAINS-GIT_COMMIT result value from a given PipelineRun.

func GetComponentSourceGitUrl

func GetComponentSourceGitUrl(object client.Object) (string, error)

GetComponentSourceGitUrl returns a string containing the CHAINS-GIT_URL result value from a given PipelineRun.

func GetOutputImage

func GetOutputImage(object client.Object) (string, error)

GetOutputImage returns a string containing the output-image parameter value from a given PipelineRun.

func GetOutputImageDigest

func GetOutputImageDigest(object client.Object) (string, error)

GetOutputImageDigest returns a string containing the IMAGE_DIGEST result value from a given PipelineRun.

func GetPRGroupFromBuildPLR

func GetPRGroupFromBuildPLR(pipelineRun *tektonv1.PipelineRun) string

GetPRGroupFromBuildPLR gets the PR group from the substring before @ from the source-branch pac annotation, for main, it generate PR group with {source-branch}-{url-org}

func GetTypeFromPipelineRun

func GetTypeFromPipelineRun(object client.Object) (string, error)

GetTypeFromPipelineRun extracts the pipeline type from the pipelineRun labels.

func IntegrationPipelineRunPredicate

func IntegrationPipelineRunPredicate() predicate.Predicate

IntegrationPipelineRunPredicate returns a predicate which filters out all objects except integration PipelineRuns that have just started or finished.

func IsBuildPipelineRun

func IsBuildPipelineRun(object client.Object) bool

IsBuildPipelineRun returns a boolean indicating whether the object passed is a PipelineRun from the Build service or not.

func IsIntegrationPipelineRun

func IsIntegrationPipelineRun(object client.Object) bool

IsIntegrationPipelineRun returns a boolean indicating whether the object passed is an Integration Component PipelineRun

func IsPLRCreatedByPACPushEvent

func IsPLRCreatedByPACPushEvent(plr *tektonv1.PipelineRun) bool

IsPLRCreatedByPACPushEvent checks if a PLR has label PipelineAsCodeEventTypeLabel and with push or Push value

func LabelBuildPipelineRun

func LabelBuildPipelineRun(ctx context.Context, pipelineRun *tektonv1.PipelineRun, key, value string, cl client.Client) error

LabelBuildPipelineRun sets annotation for a build pipelineRun in defined context and returns that pipeline

Types

type IntegrationPipelineRun

type IntegrationPipelineRun struct {
	tektonv1.PipelineRun
}

IntegrationPipelineRun is a PipelineRun alias, so we can add new methods to it in this file.

func NewIntegrationPipelineRun

func NewIntegrationPipelineRun(prefix, namespace string, integrationTestScenario v1beta2.IntegrationTestScenario) *IntegrationPipelineRun

NewIntegrationPipelineRun creates an empty PipelineRun in the given namespace. The name will be autogenerated, using the prefix passed as an argument to the function.

func (*IntegrationPipelineRun) AsPipelineRun

func (r *IntegrationPipelineRun) AsPipelineRun() *tektonv1.PipelineRun

AsPipelineRun casts the IntegrationPipelineRun to PipelineRun, so it can be used in the Kubernetes client.

func (*IntegrationPipelineRun) WithApplication

WithApplication adds the name of application as a label to the Integration PipelineRun.

func (*IntegrationPipelineRun) WithExtraParam

WithExtraParam adds an extra param to the Integration PipelineRun. If the parameter is not part of the Pipeline definition, it will be silently ignored.

func (*IntegrationPipelineRun) WithExtraParams

WithExtraParams adds all provided parameters to the Integration PipelineRun.

func (*IntegrationPipelineRun) WithFinalizer

func (iplr *IntegrationPipelineRun) WithFinalizer(finalizer string) *IntegrationPipelineRun

WithFinalizer adds a Finalizer on the Integration PipelineRun

func (*IntegrationPipelineRun) WithIntegrationAnnotations

WithIntegrationAnnotations copies the App Studio annotations from the IntegrationTestScenario to the PipelineRun

func (*IntegrationPipelineRun) WithIntegrationLabels

func (r *IntegrationPipelineRun) WithIntegrationLabels(integrationTestScenario *v1beta2.IntegrationTestScenario) *IntegrationPipelineRun

WithIntegrationLabels adds the type, optional flag and IntegrationTestScenario name as labels to the Integration PipelineRun.

func (*IntegrationPipelineRun) WithIntegrationTimeouts

func (r *IntegrationPipelineRun) WithIntegrationTimeouts(integrationTestScenario *v1beta2.IntegrationTestScenario, logger logr.Logger) *IntegrationPipelineRun

WithIntegrationTimeouts fetches the Integration timeouts from either the integrationTestScenario annotations or the environment variables and adds them to the integration PipelineRun.

func (*IntegrationPipelineRun) WithSnapshot

WithSnapshot adds a param containing the Snapshot as a json string to the integration PipelineRun. It also adds the Snapshot name label and copies the Component name label if it exists

func (*IntegrationPipelineRun) WithUpdatedTestsGitResolver

func (iplr *IntegrationPipelineRun) WithUpdatedTestsGitResolver(params map[string]string) *IntegrationPipelineRun

Updates git resolver values parameters with values of params specified in the input map updates only exsitings parameters, doens't create new ones

Jump to

Keyboard shortcuts

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