Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotateBuildPipelineRun(ctx context.Context, pipelineRun *tektonv1.PipelineRun, key, value string, ...) error
- func AnnotateBuildPipelineRunWithCreateSnapshotAnnotation(ctx context.Context, pipelineRun *tektonv1.PipelineRun, cl client.Client, ...) error
- func BuildPipelineRunCreatedPredicate() predicate.Predicate
- func BuildPipelineRunDeletingPredicate() predicate.Predicate
- func BuildPipelineRunFailedPredicate() predicate.Predicate
- func BuildPipelineRunSignedAndSucceededPredicate() predicate.Predicate
- func GenerateSHA(str string) string
- func GetComponentSourceGitCommit(object client.Object) (string, error)
- func GetComponentSourceGitUrl(object client.Object) (string, error)
- func GetOutputImage(object client.Object) (string, error)
- func GetOutputImageDigest(object client.Object) (string, error)
- func GetPRGroupFromBuildPLR(pipelineRun *tektonv1.PipelineRun) string
- func GetTypeFromPipelineRun(object client.Object) (string, error)
- func IntegrationPipelineRunPredicate() predicate.Predicate
- func IsBuildPipelineRun(object client.Object) bool
- func IsIntegrationPipelineRun(object client.Object) bool
- func IsPLRCreatedByPACPushEvent(plr *tektonv1.PipelineRun) bool
- func LabelBuildPipelineRun(ctx context.Context, pipelineRun *tektonv1.PipelineRun, key, value string, ...) error
- type IntegrationPipelineRun
- func (r *IntegrationPipelineRun) AsPipelineRun() *tektonv1.PipelineRun
- func (r *IntegrationPipelineRun) WithApplication(application *applicationapiv1alpha1.Application) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithExtraParam(name string, value tektonv1.ParamValue) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithExtraParams(params []v1beta2.PipelineParameter) *IntegrationPipelineRun
- func (iplr *IntegrationPipelineRun) WithFinalizer(finalizer string) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithIntegrationAnnotations(its *v1beta2.IntegrationTestScenario) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithIntegrationLabels(integrationTestScenario *v1beta2.IntegrationTestScenario) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithIntegrationTimeouts(integrationTestScenario *v1beta2.IntegrationTestScenario, logger logr.Logger) *IntegrationPipelineRun
- func (r *IntegrationPipelineRun) WithSnapshot(snapshot *applicationapiv1alpha1.Snapshot) *IntegrationPipelineRun
- func (iplr *IntegrationPipelineRun) WithUpdatedTestsGitResolver(params map[string]string) *IntegrationPipelineRun
Constants ¶
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" )
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" )
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 ¶
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 ¶
BuildPipelineRunCreatedPredicate returns a predicate which filters out all objects except Build PipelineRuns which have been created
func BuildPipelineRunDeletingPredicate ¶
BuildPipelineRunDeletingPredicate returns a predicate which filters out all objects except Build PipelineRuns which have been updated to deleting
func BuildPipelineRunFailedPredicate ¶
BuildPipelineRunFailedPredicate returns a predicate which filters out all objects except Build PipelineRuns which have finished and have failed.
func BuildPipelineRunSignedAndSucceededPredicate ¶
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 ¶
GenerateSHA generate a 63 charactors sha string used by pipelineRun and snapshot label
func GetComponentSourceGitCommit ¶
GetComponentSourceGitCommit returns a string containing the CHAINS-GIT_COMMIT result value from a given PipelineRun.
func GetComponentSourceGitUrl ¶
GetComponentSourceGitUrl returns a string containing the CHAINS-GIT_URL result value from a given PipelineRun.
func GetOutputImage ¶
GetOutputImage returns a string containing the output-image parameter value from a given PipelineRun.
func GetOutputImageDigest ¶
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 ¶
GetTypeFromPipelineRun extracts the pipeline type from the pipelineRun labels.
func IntegrationPipelineRunPredicate ¶
IntegrationPipelineRunPredicate returns a predicate which filters out all objects except integration PipelineRuns that have just started or finished.
func IsBuildPipelineRun ¶
IsBuildPipelineRun returns a boolean indicating whether the object passed is a PipelineRun from the Build service or not.
func IsIntegrationPipelineRun ¶
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 ¶
func (r *IntegrationPipelineRun) WithApplication(application *applicationapiv1alpha1.Application) *IntegrationPipelineRun
WithApplication adds the name of application as a label to the Integration PipelineRun.
func (*IntegrationPipelineRun) WithExtraParam ¶
func (r *IntegrationPipelineRun) WithExtraParam(name string, value tektonv1.ParamValue) *IntegrationPipelineRun
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 ¶
func (r *IntegrationPipelineRun) WithExtraParams(params []v1beta2.PipelineParameter) *IntegrationPipelineRun
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 ¶
func (r *IntegrationPipelineRun) WithIntegrationAnnotations(its *v1beta2.IntegrationTestScenario) *IntegrationPipelineRun
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 ¶
func (r *IntegrationPipelineRun) WithSnapshot(snapshot *applicationapiv1alpha1.Snapshot) *IntegrationPipelineRun
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