gitops

package
v0.0.0-...-a7e4d21 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

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

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

	// ReleaseLabelPrefix contains the prefix applied to to labels and annotations related to release process.
	ReleaseLabelPrefix = "release.appstudio.openshift.io"

	// AutoReleaseLabel contains the label that allows users to overwrite the release behaviour of Snapshots
	AutoReleaseLabel = ReleaseLabelPrefix + "/auto-release"

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

	// SnapshotTypeLabel contains the type of the Snapshot.
	SnapshotTypeLabel = "test.appstudio.openshift.io/type"

	// SnapshotIntegrationTestRun contains name of test we want to trigger run
	SnapshotIntegrationTestRun = "test.appstudio.openshift.io/run"

	// AppstudioLabelPrefix contains application, component, build-pipelinerun etc.
	AppstudioLabelPrefix = "appstudio.openshift.io"

	// SnapshotLabel contains the name of the Snapshot within appstudio
	SnapshotLabel = "appstudio.openshift.io/snapshot"

	// SnapshotTestScenarioLabel contains the name of the Snapshot test scenario.
	SnapshotTestScenarioLabel = "test.appstudio.openshift.io/scenario"

	// SnapshotTestsStatusAnnotation contains json data with test results of the particular snapshot
	SnapshotTestsStatusAnnotation = "test.appstudio.openshift.io/status"

	// (Deprecated) SnapshotPRLastUpdate contains timestamp of last time PR was updated
	SnapshotPRLastUpdate = "test.appstudio.openshift.io/pr-last-update"

	// SnapshotGitSourceRepoURLAnnotation contains URL of the git source repository (usually needed for forks)
	SnapshotGitSourceRepoURLAnnotation = "test.appstudio.openshift.io/source-repo-url"

	// PipelineAsCodeGitSourceURLAnnotation contains the source repository url information
	PipelineAsCodeGitSourceURLAnnotation = PipelinesAsCodePrefix + "/source-repo-url"

	// PipelineAsCodeSourceBranchAnnotation contains the source repository branch information
	PipelineAsCodeSourceBranchAnnotation = PipelinesAsCodePrefix + "/source-branch"

	// SnapshotStatusReportAnnotation contains metadata of tests related to status reporting to git provider
	SnapshotStatusReportAnnotation = "test.appstudio.openshift.io/git-reporter-status"

	// PRGroupAnnotation contains the pr group name
	PRGroupAnnotation = "test.appstudio.openshift.io/pr-group"

	// PRGroupHashLabel contains the pr group name in sha format
	PRGroupHashLabel = "test.appstudio.openshift.io/pr-group-sha"

	// PRGroupCreationAnnotation contains the info of groupsnapshot creation
	PRGroupCreationAnnotation = "test.appstudio.openshift.io/create-groupsnapshot-status"

	// GitReportingFailureAnnotation contains information about git reporting failures
	GitReportingFailureAnnotation = "test.appstudio.openshift.io/git-reporting-failure"

	// BuildPipelineRunResultAnnotationPrefix is the prefix for annotations derived from build PipelineRun results
	BuildPipelineRunResultAnnotationPrefix = TestLabelPrefix + "/result-"

	// BuildPipelineRunShouldReleaseAnnotation contains the SHOULD_RELEASE result from the build PipelineRun
	BuildPipelineRunShouldReleaseAnnotation = BuildPipelineRunResultAnnotationPrefix + "should-release"

	// BuildPipelineRunStartTime contains the start time of build pipelineRun
	BuildPipelineRunStartTime = "test.appstudio.openshift.io/pipelinerunstarttime"

	// BuildPipelineLastBuiltTime contains the time of the last built pipelineRun
	BuildPipelineLastBuiltTime = "test.appstudio.openshift.io/lastbuilttime"

	// IntegrationWorkflowAnnotation contains the workflow type that triggered the snapshot (push or pull-request)
	IntegrationWorkflowAnnotation = "test.appstudio.openshift.io/integration-workflow"

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

	// BuildPipelineRunFinishTimeLabel contains the build PipelineRun finish time of the Snapshot.
	BuildPipelineRunFinishTimeLabel = "test.appstudio.openshift.io/pipelinerunfinishtime"

	// GroupSnapshotInfoAnnotation contains the component snapshot info included in group snapshot
	GroupSnapshotInfoAnnotation = "test.appstudio.openshift.io/group-test-info"

	// PRStatusAnnotation contains the status of the PR
	PRStatusAnnotation = "test.appstudio.openshift.io/pr-status"

	// BuildPipelineRunNameLabel contains the build PipelineRun name
	BuildPipelineRunNameLabel = AppstudioLabelPrefix + "/build-pipelinerun"

	// ApplicationNameLabel contains the name of the application
	ApplicationNameLabel = AppstudioLabelPrefix + "/application"

	// ComponentGroupNameLabel contains the name of the ComponentGroup
	ComponentGroupNameLabel = AppstudioLabelPrefix + "/component-group"

	// SnapshotComponentType is the type of Snapshot which was created for a single component build.
	SnapshotComponentType = "component"

	// SnapshotOverrideType is the type of Snapshot which was created for override Global Candidate List.
	SnapshotOverrideType = "override"

	// SnapshotGroupType is the type of Snapshot which was created for pull request groups.
	SnapshotGroupType = "group"

	// PipelineAsCodeEventTypeLabel is the type of event which triggered the pipelinerun in build service
	PipelineAsCodeEventTypeLabel = PipelinesAsCodePrefix + "/event-type"

	// PipelineAsCodeGitProviderLabel is the git provider which triggered the pipelinerun in build service.
	PipelineAsCodeGitProviderLabel = PipelinesAsCodePrefix + "/git-provider"

	// PipelineAsCodeGitProviderAnnotation is the git provider which triggered the pipelinerun in build service.
	PipelineAsCodeGitProviderAnnotation = PipelinesAsCodePrefix + "/git-provider"

	// PipelineAsCodeSHALabel is the commit which triggered the pipelinerun in build service.
	PipelineAsCodeSHALabel = PipelinesAsCodePrefix + "/sha"

	// PipelineAsCodeURLOrgLabel is the organization for the git repo which triggered the pipelinerun in build service.
	PipelineAsCodeURLOrgLabel = PipelinesAsCodePrefix + "/url-org"

	// PipelineAsCodeURLRepositoryLabel is the git repository which triggered the pipelinerun in build service.
	PipelineAsCodeURLRepositoryLabel = PipelinesAsCodePrefix + "/url-repository"

	// PipelineAsCodeRepoURLAnnotation is the URL to the git repository which triggered the pipelinerun in build service.
	PipelineAsCodeRepoURLAnnotation = PipelinesAsCodePrefix + "/repo-url"

	// PipelineAsCodeTargetBranchAnnotation is the SHA of the git revision which triggered the pipelinerun in build service.
	PipelineAsCodeTargetBranchAnnotation = PipelinesAsCodePrefix + "/branch"

	// PipelineAsCodeInstallationIDAnnotation is the GitHub App installation ID for the git repo which triggered the pipelinerun in build service.
	PipelineAsCodeInstallationIDAnnotation = PipelinesAsCodePrefix + "/installation-id"

	// PipelineAsCodePullRequestAnnotation is the git repository's pull request identifier
	PipelineAsCodePullRequestAnnotation = PipelinesAsCodePrefix + "/pull-request"

	// PipelineAsCodeSourceProjectIDAnnotation is the source project ID for gitlab
	PipelineAsCodeSourceProjectIDAnnotation = PipelinesAsCodePrefix + "/source-project-id"

	// PipelineAsCodeTargetProjectIDAnnotation is the target project ID for gitlab
	PipelineAsCodeTargetProjectIDAnnotation = PipelinesAsCodePrefix + "/target-project-id"

	// PipelineAsCodeRepoUrlAnnotation is the target project Repo Url
	PipelineAsCodeRepoUrlAnnotation = PipelinesAsCodePrefix + "/repo-url"

	// PipelineAsCodeSHAAnnotation is the commit which triggered the pipelinerun in build service.
	PipelineAsCodeSHAAnnotation = PipelinesAsCodePrefix + "/sha"

	// PipelineAsCodePushType is the type of push event which triggered the pipelinerun in build service
	PipelineAsCodePushType = "push"

	// PipelineAsCodeGLPushType is the type of gitlab push event which triggered the pipelinerun in build service
	PipelineAsCodeGLPushType = "Push"

	// PipelineAsCodePullRequestType is the type of pull_request event which triggered the pipelinerun in build service
	PipelineAsCodePullRequestType = "pull_request"

	// PipelineAsCodeMergeRequestType is the type of merge request event which triggered the pipelinerun in build service
	PipelineAsCodeMergeRequestType = "Merge Request"

	// PipelineAsCodeGLMergeRequestType is the type of gitlab merge request event marked in label which triggered the pipelinerun in build service
	PipelineAsCodeMergeUnderscoreRequestType = "Merge_Request"

	// PipelineAsCodeRetestType is the type of retest event which triggered the pipelinerun in build service by commenting /retest
	PipelineAsCodeRetestType = "retest-all-comment"

	// IntegrationWorkflowPushValue is the value for push workflow snapshots
	IntegrationWorkflowPushValue = "push"

	// IntegrationWorkflowPullRequestValue is the value for pull request workflow snapshots
	IntegrationWorkflowPullRequestValue = "pull-request"

	// PipelineAsCodeGitHubProviderType is the git provider type for a GitHub event which triggered the pipelinerun in build service.
	PipelineAsCodeGitHubProviderType = "github"

	// PipelineAsCodeGitLabProviderType is the git provider type for a GitLab event which triggered the pipelinerun in build service.
	PipelineAsCodeGitLabProviderType = "gitlab"

	// PipelineAsCodeForgejoProviderType is the git provider type for a Forgejo event which triggered the pipelinerun in build service.
	PipelineAsCodeForgejoProviderType = "forgejo"

	// PipelineAsCodeGiteaProviderType is the git provider type for Gitea. PaC uses this when targeting Forgejo until PaC adds full Forgejo support.
	// TODO: Remove this once PaC adds full Forgejo support expected March 2026
	PipelineAsCodeGiteaProviderType = "gitea"

	// PipelineAsCodeGitHubMergeQueueBranchPrefix is the prefix added to temporary branches which are created for merge queues
	PipelineAsCodeGitHubMergeQueueBranchPrefix = "gh-readonly-queue/"

	// GitRefBranchPrefix is the git prefix denoting a reference is a branch
	GitRefBranchPrefix = "refs/heads/"

	// AppStudioTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
	AppStudioTestSucceededCondition = "AppStudioTestSucceeded"

	// LegacyTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
	LegacyTestSucceededCondition = "HACBSStudioTestSucceeded"

	// AppStudioIntegrationStatusCondition is the condition for marking the AppStudio integration status of the Snapshot.
	AppStudioIntegrationStatusCondition = "AppStudioIntegrationStatus"

	// LegacyIntegrationStatusCondition is the condition for marking the AppStudio integration status of the Snapshot.
	LegacyIntegrationStatusCondition = "HACBSIntegrationStatus"

	// SnapshotAutoReleasedCondition is the condition for marking if Snapshot was auto-released released with AppStudio.
	SnapshotAutoReleasedCondition = "AutoReleased"

	// ParentSnapshotsCreatedCondition is the condition marking whether snapshots for all parent ComponentGroups for the
	// ComponentGroup that the snapshot belongs to have been created
	ParentSnapshotsCreatedCondition = "ParentSnapshotsCreated"

	// SnapshotSupersededMessage is the AutoReleased condition message when
	// an older Snapshot is skipped by a newer Snapshot for the same Application.
	SnapshotSupersededMessage = "Released in newer Snapshot"

	// SnapshotAddedToGlobalCandidateListCondition is the condition for marking if Snapshot's component was added to
	// the global candidate list.
	SnapshotAddedToGlobalCandidateListCondition = "AddedToGlobalCandidateList"

	// AppStudioTestSucceededConditionSatisfied is the reason that's set when the AppStudio tests succeed.
	AppStudioTestSucceededConditionSatisfied = "Passed"

	// AppStudioTestSucceededConditionFailed is the reason that's set when the AppStudio tests fail.
	AppStudioTestSucceededConditionFailed = "Failed"

	// AppStudioIntegrationStatusCanceled is the reason that's set when the AppStudio tests cancel because of being superseded by newer Snapshot.
	AppStudioIntegrationStatusCanceled = "Canceled"

	// AppStudioIntegrationStatusInvalid is the reason that's set when the AppStudio integration gets into an invalid state.
	AppStudioIntegrationStatusInvalid = "Invalid"

	// AppStudioIntegrationStatusErrorOccured is the reason that's set when the AppStudio integration gets into an error state.
	AppStudioIntegrationStatusErrorOccured = "ErrorOccured"

	// AppStudioIntegrationStatusInProgress is the reason that's set when the AppStudio tests gets into an in progress state.
	AppStudioIntegrationStatusInProgress = "InProgress"

	// AppStudioIntegrationStatusFinished is the reason that's set when the AppStudio tests finish.
	AppStudioIntegrationStatusFinished = "Finished"

	// AppStudioIntegrationStatusCancelled is the reason that's set when the AppStudio tests pipelinerun gets cancelled.
	AppStudioIntegrationStatusCancelled = "CancelledRunFinally"

	// PRGroupCancelledAnnotation helps track PipelineRuns that were stopped before completion.
	PRGroupCancelledAnnotation = PipelinesAsCodePrefix + "/cancelled"

	// IntegrationTestStatusPendingGithub is the status reported to github when integration test is in a queue
	IntegrationTestStatusPendingGithub = "pending"

	// IntegrationTestStatusSuccessGithub is the status reported to github when integration test succeed
	IntegrationTestStatusSuccessGithub = "success"

	// IntegrationTestStatusFailureGithub is the status reported to github when integration test fail
	IntegrationTestStatusFailureGithub = "failure"

	// IntegrationTestStatusErrorGithub is the status reported to github when integration test experience error
	IntegrationTestStatusErrorGithub = "error"

	// IntegrationTestStatusInProgressGithub is the status reported to github when integration test is in progress
	IntegrationTestStatusInProgressGithub = "in_progress"

	// IntegrationTestStatusCancelledGithub is the status reported to github when integration test is cancelled
	IntegrationTestStatusCancelledGithub = "cancelled"

	// IntegrationTestStatusNeutralGithub is the status reported to github when integration test is neutral
	IntegrationTestStatusNeutralGithub = "neutral"

	// ComponentNameForGroupSnapshot is the component name used for group snapshots
	ComponentNameForGroupSnapshot = "pr group"

	// FailedToCreateGroupSnapshotMsg is the message when group snapshot creation fails
	FailedToCreateGroupSnapshotMsg = "Failed to create group snapshot for pr group"

	// GroupSnapshotCreationFailureReported is the message when group snapshot creation failure is reported to git provider
	GroupSnapshotCreationFailureReported = "group snapshot creation failure is reported to git provider"

	// Annotation that tells the integration service to skip checks for whether a build or snapshot is superseded
	IgnoreSupersessionAnnotation = TestLabelPrefix + "/ignore-supersession"

	// PRStatusMerged indicates that the PR has been merged
	PRStatusMerged = "merged"

	// Success is the success status value
	Success = "Success"

	// AddedToGlobalCandidateListAnnotation is the annotation for marking if Snapshot/build PLR's component was added to the global candidate list.
	AddedToGlobalCandidateListAnnotation = "test.appstudio.openshift.io/added-to-global-candidate-list"

	// GitCommentPolicyAnnotation is the annotation to control git comment policy for the component
	GitCommentPolicyAnnotation = "test.appstudio.openshift.io/comment_strategy"
	// GitCommentPolicyAllDisabled is the value to disable all test comments for the component got pac repository
	GitCommentPolicyAllDisabled = "disable_all"

	// ChildSnapshotAnnotation is used in nested snapshots. Denotes the name of the child snapshot whose creation triggered the creation of the snapshot
	// on which the annotation is set
	ChildSnapshotAnnotation = TestLabelPrefix + "/child-snapshot"
)

Variables

View Source
var SnapshotComponentLabel = tektonconsts.ComponentNameLabel

SnapshotComponentLabel contains the name of the updated Snapshot component - it should match the pipeline label.

Functions

func AddIntegrationTestRerunLabel

func AddIntegrationTestRerunLabel(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, integrationTestScenarioName string) error

AddIntegrationTestRerunLabel adding re-run label to snapshot

func AddParentSnapshotDataToSnapshotStatus

func AddParentSnapshotDataToSnapshotStatus(snapshot *applicationapiv1alpha1.Snapshot, created bool, parentCG, parentSnapshot, message string)

func AnnotateComponent

func AnnotateComponent(ctx context.Context, component *applicationapiv1alpha1.Component, key, value string, cl client.Client) error

AnnotateComponent sets annotation for a component in defined context, return error if meeting it

func AnnotateSnapshot

func AnnotateSnapshot(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot, key, value string, cl client.Client) error

AnnotateSnapshot sets annotation for a snapshot in defined context, return error if meeting it

func BuildResultAnnotationKey

func BuildResultAnnotationKey(resultName string) string

BuildResultAnnotationKey normalizes a PipelineRun result name into a Snapshot annotation key. e.g. "SHOULD_RELEASE" → "test.appstudio.openshift.io/result-should-release"

func CanSnapshotBePromoted

func CanSnapshotBePromoted(snapshot *applicationapiv1alpha1.Snapshot) (bool, []string)

CanSnapshotBePromoted checks if the Snapshot in question can be promoted for deployment and release.

func CancelPipelineRuns

func CancelPipelineRuns(c client.Client, ctx context.Context, logger helpers.IntegrationLogger, integrationTestPipelineRuns []tektonv1.PipelineRun) error

func CompareSnapshots

func CompareSnapshots(expectedSnapshot *applicationapiv1alpha1.Snapshot, foundSnapshot *applicationapiv1alpha1.Snapshot) bool

CompareSnapshots compares two Snapshots and returns boolean true if their images match exactly.

func CopyBuildPipelineRunResultsToSnapshot

func CopyBuildPipelineRunResultsToSnapshot(pipelineRun *tektonv1.PipelineRun, snapshot *applicationapiv1alpha1.Snapshot)

CopyBuildPipelineRunResultsToSnapshot copies all string-typed results from a build PipelineRun into Snapshot annotations so downstream consumers can access them without loading the PLR.

func CopySnapshotLabelsAndAnnotations

func CopySnapshotLabelsAndAnnotations(object *metav1.ObjectMeta, snapshot *applicationapiv1alpha1.Snapshot, componentName string, source *metav1.ObjectMeta, prefixes []string, objectIsApplication bool)

CopySnapshotLabelsAndAnnotations coppies labels and annotations from build pipelineRun or tested snapshot into regular snapshot ObjectMeta: metav1.ObjectMeta{ TODO: replace 'object' with 'componentGroup' after application is deprecated. Also delete Application bool

func CopyTempGroupSnapshotLabelsAndAnnotations

func CopyTempGroupSnapshotLabelsAndAnnotations(object *metav1.ObjectMeta, snapshot *applicationapiv1alpha1.Snapshot, componentName string, source *metav1.ObjectMeta, prefixes []string, objectIsApplication bool)

CopyTempGroupSnapshotLabelsAndAnnotations coppies labels and annotations from build pipelineRun or tested snapshot into regular snapshot

func EnrichBuiltComponentSourceGitContext

func EnrichBuiltComponentSourceGitContext(componentSource *applicationapiv1alpha1.ComponentSource, component *applicationapiv1alpha1.Component, componentVersion string)

EnrichBuiltComponentSourceGitContext sets GitSource.Context on the built component source when it is still empty. When componentVersion is set, matching spec.source.versions[].context takes precedence over spec.source.git.context; otherwise top-level git context is used. This aligns the built row with GetComponentSourceFromComponent for sibling components.

func EvaluateSnapshotAutoReleaseAnnotation

func EvaluateSnapshotAutoReleaseAnnotation(autoReleaseExpr string, snapshot *applicationapiv1alpha1.Snapshot, shouldRelease bool) (bool, error)

EvaluateSnapshotAutoReleaseAnnotation evaluates the provided auto-release annotation CEL-like expression against the given Snapshot and returns whether it allows auto-release. The shouldRelease parameter is made available via the shouldRelease() CEL function, which reflects the build PipelineRun's SHOULD_RELEASE result. Note: shouldRelease only gates releases if the CEL expression actually calls shouldRelease(). An expression like "true" will bypass gating entirely.

func ExtractPullRequestNumberFromMergeQueueSnapshot

func ExtractPullRequestNumberFromMergeQueueSnapshot(snapshot *applicationapiv1alpha1.Snapshot) string

ExtractPullRequestNumberFromMergeQueueSnapshot attempts to extract the pull request number for the Snapshot If the pull request annotation is present, it returns it, otherwise it extracts it from the source branch name

func FilterIntegrationTestScenariosWithContext

func FilterIntegrationTestScenariosWithContext(scenarios *[]v1beta2.IntegrationTestScenario, snapshot *applicationapiv1alpha1.Snapshot) *[]v1beta2.IntegrationTestScenario

FilterIntegrationTestScenariosWithContext returns a filtered list of IntegrationTestScenario from the given list of IntegrationTestScenarios compared against the given Snapshot based on individual IntegrationTestScenario contexts

func FindMatchingSnapshot

func FindMatchingSnapshot(application *applicationapiv1alpha1.Application, allSnapshots *[]applicationapiv1alpha1.Snapshot, expectedSnapshot *applicationapiv1alpha1.Snapshot) *applicationapiv1alpha1.Snapshot

FindMatchingSnapshot tries to find the expected Snapshot with the same set of images.

func FindMatchingSnapshotComponent

func FindMatchingSnapshotComponent(snapshot *applicationapiv1alpha1.Snapshot, componentName string) applicationapiv1alpha1.SnapshotComponent

FindMatchingSnapshotComponent find the snapshot component from the given snapshot according to the name of the given component name

func GenerateSnapshotNameWithTimestamp

func GenerateSnapshotNameWithTimestamp(prefix string, unixMilli int64, suffix ...string) string

GenerateSnapshotNameWithTimestamp generates a snapshot name using the application prefix and a timestamp with millisecond precision. The format is: {prefix}-{YYYYMMDD-HHMMSS-mmm}[-{suffix}] where prefix is truncated to maxPrefixLength (43 chars) or maxPrefixLengthWithSuffix (41 chars) if suffix is provided to accommodate the 19-character timestamp within Kubernetes' 63-character limit. suffix is optional and used for collision handling (2 characters).

func GetAppStudioTestsFinishedTime

func GetAppStudioTestsFinishedTime(snapshot *applicationapiv1alpha1.Snapshot) (metav1.Time, bool)

GetAppStudioTestsFinishedTime finds the timestamp of tests succeeded condition

func GetComponentSourceFromComponent

func GetComponentSourceFromComponent(component *applicationapiv1alpha1.Component) (*applicationapiv1alpha1.ComponentSource, error)

GetComponentSourceFromComponent gets the component source from the given Component as Revision and set Component.Status.LastBuiltCommit as Component.Source.GitSource.Revision if it is defined.

func GetIntegrationTestRunLabelValue

func GetIntegrationTestRunLabelValue(obj metav1.Object) (string, bool)

GetIntegrationTestRunLabelValue returns value of the label responsible for re-running tests

func GetLatestUpdateTime

func GetLatestUpdateTime(snapshot *applicationapiv1alpha1.Snapshot) (time.Time, error)

Deprecated

func GetPRGroup

func GetPRGroup(object client.Object) (string, string)

GetPRGroup gets the value of label test.appstudio.openshift.io/pr-group-sha and annotation from component snapshot or pipelinerun

func GetShaFromSnapshot

func GetShaFromSnapshot(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) string

GetShaFromSnapshot returns the value of "pac.test.appstudio.openshift.io/sha" annotation of length 7 for short SHA from the Snapshot, if it exists. If the SHA is shorter than 7 characters, it returns it as is. If the SHA is empty, it logs an info message and returns an empty string.

func GetSourceRepoOwnerFromSnapshot

func GetSourceRepoOwnerFromSnapshot(snapshot *applicationapiv1alpha1.Snapshot) string

func GetTestSucceededCondition

func GetTestSucceededCondition(snapshot *applicationapiv1alpha1.Snapshot) (condition *metav1.Condition, ok bool)

GetTestSucceededCondition checks status of tests on the snapshot

func HasPRGroupProcessed

func HasPRGroupProcessed(snapshot *applicationapiv1alpha1.Snapshot) bool

HasPRGroupProcessed checks if the group creation has been handled for this snapshot by snapshot adapter when to avoid duplicate check when reconciling this snapshot, if yes, won't handle the snapshot again the annotation updated from other component pipelinerun should not be counted in

func HasSameGitSourceAndPRWithProcessedSnapshot

func HasSameGitSourceAndPRWithProcessedSnapshot(latestSnapshot, snapshot *applicationapiv1alpha1.Snapshot) bool

HasSameGitSourceAndPRWithProcessedSnapshot checks if the given snapshot has the same git source and pull request number as the latest snapshot, which means the same PR, to avoid processing the same PR with multiple snapshots or pipelineruns

func HasSnapshotRerunLabelChanged

func HasSnapshotRerunLabelChanged(objectOld, objectNew client.Object) bool

HasSnapshotRerunLabelChanged returns a boolean indicating whether the Snapshot label for re-running integration test has changed. If the objects passed to this function are not Snapshots, the function will return false.

func HasSnapshotTestAnnotationChanged

func HasSnapshotTestAnnotationChanged(objectOld, objectNew client.Object) bool

HasSnapshotTestAnnotationChanged returns a boolean indicating whether the Snapshot annotation has changed. If the objects passed to this function are not Snapshots, the function will return false.

func HasSnapshotTestingChangedToFinished

func HasSnapshotTestingChangedToFinished(objectOld, objectNew client.Object) bool

HasSnapshotTestingChangedToFinished returns a boolean indicating whether the Snapshot testing status has changed to finished. If the objects passed to this function are not Snapshots, the function will return false.

func HaveAppStudioTestsFinished

func HaveAppStudioTestsFinished(snapshot *applicationapiv1alpha1.Snapshot) bool

HaveAppStudioTestsFinished checks if the AppStudio tests have finished by checking if the AppStudio Test Succeeded condition is set.

func HaveAppStudioTestsSucceeded

func HaveAppStudioTestsSucceeded(snapshot *applicationapiv1alpha1.Snapshot) bool

HaveAppStudioTestsSucceeded checks if the AppStudio tests have finished by checking if the AppStudio Test Succeeded condition is set.

func HaveGitSource

func HaveGitSource(snapshotComponent applicationapiv1alpha1.SnapshotComponent) bool

HaveGitSource checks if snapshotComponent contains non-empty source.git field and have both url and revision fields defined

func HaveGitSourceInComponent

func HaveGitSourceInComponent(component applicationapiv1alpha1.Component) bool

HaveGitSourceInComponent checks if component contains non-empty source.git field and have both url and revision fields defined

func IgnoreSupersession

func IgnoreSupersession(object metav1.ObjectMeta) bool

func IntegrationSnapshotChangePredicate

func IntegrationSnapshotChangePredicate() predicate.Predicate

IntegrationSnapshotChangePredicate returns a predicate which filters out all objects except snapshot is deleted and requires HasSnapshotTestingChangedToFinished for update events.

func IsAllCommentDisabledForPacRepositoryInComponent

func IsAllCommentDisabledForPacRepositoryInComponent(ctx context.Context, adapterClient client.Client, component *applicationapiv1alpha1.Component) (bool, error)

IsAllCommentDisabledForPacRepositoryInComponent checks if all git comments are disabled in pac repository for the given component

func IsCommentDisabled

func IsCommentDisabled(ctx context.Context, adapterClient client.Client, component *applicationapiv1alpha1.Component) (bool, error)

func IsComponentSnapshot

func IsComponentSnapshot(snapshot *applicationapiv1alpha1.Snapshot) bool

func IsComponentSnapshotCreatedByPACPushEvent

func IsComponentSnapshotCreatedByPACPushEvent(snapshot *applicationapiv1alpha1.Snapshot) bool

func IsContextValidForSnapshot

func IsContextValidForSnapshot(scenarioContextName string, snapshot *applicationapiv1alpha1.Snapshot) bool

IsContextValidForSnapshot checks the context and compares it against the Snapshot to determine if it applies

func IsGroupSnapshot

func IsGroupSnapshot(snapshot *applicationapiv1alpha1.Snapshot) bool

IsGroupSnapshot returns true if snapshot label 'test.appstudio.openshift.io/type' is 'group'

func IsIntegrationTestCommentDisabledForComponent

func IsIntegrationTestCommentDisabledForComponent(component *applicationapiv1alpha1.Component) bool

IsIntegrationTestCommentDisabledForComponent checks if all git comments are disabled for the integration test status of given component

func IsOverrideSnapshot

func IsOverrideSnapshot(snapshot *applicationapiv1alpha1.Snapshot) bool

IsOverrideSnapshot returns true if snapshot label 'test.appstudio.openshift.io/type' is 'override'

func IsScenarioApplicableToSnapshotsContext

func IsScenarioApplicableToSnapshotsContext(scenario *v1beta2.IntegrationTestScenario, snapshot *applicationapiv1alpha1.Snapshot) bool

IsScenarioApplicableToSnapshotsContext checks the contexts list for a given IntegrationTestScenario and compares it against the Snapshot to determine if the scenario applies to it

func IsSnapshotAutoReleaseDisabled

func IsSnapshotAutoReleaseDisabled(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotAutoReleaseDisabled checks if a snapshot has a AutoReleaseLabel label and if its value is "false"

func IsSnapshotCreatedByPACMergeQueueEvent

func IsSnapshotCreatedByPACMergeQueueEvent(snapshot *applicationapiv1alpha1.Snapshot) bool

func IsSnapshotCreatedByPACPushEvent

func IsSnapshotCreatedByPACPushEvent(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotCreatedByPACPushEvent checks if a snapshot has label PipelineAsCodeEventTypeLabel and with push value if the label doesn't exist for some manual snapshot

func IsSnapshotCreatedBySamePACEvent

func IsSnapshotCreatedBySamePACEvent(snapshot1, snapshot2 *applicationapiv1alpha1.Snapshot) bool

IsSnapshotCreatedBySamePACEvent checks if the two snapshot are created by the same PAC event or they don't have event type

func IsSnapshotError

func IsSnapshotError(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotError if the AppStudio Integration Status condition is in ErrorOcurred status.

func IsSnapshotIntegrationStatusMarkedAsFinished

func IsSnapshotIntegrationStatusMarkedAsFinished(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotIntegrationStatusMarkedAsFinished returns true if snapshot is marked as finished or canceled

func IsSnapshotMarkedAsAddedToGlobalCandidateList

func IsSnapshotMarkedAsAddedToGlobalCandidateList(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsAddedToGlobalCandidateList returns true if snapshot's AddedToGlobalCandidateListAnnotation result is marked as true to global candidate list

func IsSnapshotMarkedAsAddedToGlobalCandidateList_Legacy

func IsSnapshotMarkedAsAddedToGlobalCandidateList_Legacy(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsAddedToGlobalCandidateList_Legacy is old way to track GCL update status by checking statusCondition and returns true if snapshot's component is marked as added to global candidate list

func IsSnapshotMarkedAsAutoReleased

func IsSnapshotMarkedAsAutoReleased(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsAutoReleased returns true if snapshot is marked as deployed to root environments

func IsSnapshotMarkedAsCanceled

func IsSnapshotMarkedAsCanceled(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsCanceled returns true if snapshot is marked as AppStudioIntegrationStatusCanceled

func IsSnapshotMarkedAsFailed

func IsSnapshotMarkedAsFailed(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsFailed returns true if snapshot is marked as failed

func IsSnapshotMarkedAsInvalid

func IsSnapshotMarkedAsInvalid(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsInvalid returns true if snapshot is marked as failed

func IsSnapshotMarkedAsPassed

func IsSnapshotMarkedAsPassed(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotMarkedAsPassed returns true if snapshot is marked as passed

func IsSnapshotNotStarted

func IsSnapshotNotStarted(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotNotStarted checks if the AppStudio Integration Status condition is not in progress status.

func IsSnapshotStatusConditionSet

func IsSnapshotStatusConditionSet(snapshot *applicationapiv1alpha1.Snapshot, conditionType string, conditionStatus metav1.ConditionStatus, reason string) bool

IsSnapshotStatusConditionSet checks if the condition with the conditionType in the status of Snapshot has been marked as the conditionStatus and reason.

func IsSnapshotValid

func IsSnapshotValid(snapshot *applicationapiv1alpha1.Snapshot) bool

IsSnapshotValid checks if the AppStudio Integration Status condition is not invalid.

func MarkSnapshotAsAddedToGlobalCandidateList

func MarkSnapshotAsAddedToGlobalCandidateList(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsAddedToGlobalCandidateList updates the AddedToGlobalCandidateListAnnotation for the Snapshot. If the patch command fails, an error will be returned.

func MarkSnapshotAsAutoReleased

func MarkSnapshotAsAutoReleased(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsAutoReleased updates the SnapshotAutoReleasedCondition for the Snapshot to 'AutoReleased'. If the patch command fails, an error will be returned.

func MarkSnapshotAsCanceled

func MarkSnapshotAsCanceled(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsCanceled updates the AppStudio Test canceled condition for the Snapshot to 'Canceled'. If the patch command fails, an error will be returned.

func MarkSnapshotAsFailed

func MarkSnapshotAsFailed(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsFailed updates the AppStudio Test succeeded condition for the Snapshot to failed. If the patch command fails, an error will be returned.

func MarkSnapshotAsInvalid

func MarkSnapshotAsInvalid(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsInvalid updates the AppStudio integration status condition for the Snapshot to invalid. If the patch command fails, an error will be returned.

func MarkSnapshotAsPassed

func MarkSnapshotAsPassed(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotAsPassed updates the AppStudio Test succeeded condition for the Snapshot to passed. If the patch command fails, an error will be returned.

func MarkSnapshotIntegrationStatusAsFinished

func MarkSnapshotIntegrationStatusAsFinished(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotIntegrationStatusAsFinished sets the AppStudio integration status condition for the Snapshot to Finished.

func MarkSnapshotIntegrationStatusAsInProgress

func MarkSnapshotIntegrationStatusAsInProgress(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

MarkSnapshotIntegrationStatusAsInProgress sets the AppStudio integration status condition for the Snapshot to In Progress.

func NewSnapshot

NewSnapshot creates a new snapshot based on the supplied application and components TODO: Remove this function once application model is fully deprecated [APPLICATION] - a matching function which supports ComponentGroups is located in the snapshot package

func NewSnapshotIntegrationTestStatusesFromSnapshot

func NewSnapshotIntegrationTestStatusesFromSnapshot(s *applicationapiv1alpha1.Snapshot) (*intgteststat.SnapshotIntegrationTestStatuses, error)

NewSnapshotIntegrationTestStatusesFromSnapshot creates new SnapshotTestStatus struct from snapshot annotation

func NotifyComponentSnapshotsInGroupSnapshot

func NotifyComponentSnapshotsInGroupSnapshot(ctx context.Context, cl client.Client, componentSnapshotInfos []ComponentSnapshotInfo, msg string) error

NotifyComponentSnapshotsInGroupSnapshot annotate the msg to the given component snapshots in componentSnapshotInfos

func ParentSnapshotsCreated

func ParentSnapshotsCreated(snapshot *applicationapiv1alpha1.Snapshot) bool

func PrepareSnapshot

func PrepareSnapshot(ctx context.Context, adapterClient client.Client, application *applicationapiv1alpha1.Application, applicationComponents *[]applicationapiv1alpha1.Component, component *applicationapiv1alpha1.Component, newContainerImage string, newComponentSource *applicationapiv1alpha1.ComponentSource) (*applicationapiv1alpha1.Snapshot, error)

PrepareSnapshot prepares the Snapshot for a given application, components and the updated component (if any). In case the Snapshot can't be created, an error will be returned.

func PrepareTempGroupSnapshot

func PrepareTempGroupSnapshot(application *applicationapiv1alpha1.Application, snapshot *applicationapiv1alpha1.Snapshot) *applicationapiv1alpha1.Snapshot

PrepareTempGroupSnapshot will prepare a temp group snapshot used to check the integration test scenario that should be applied to the group snapshot under that application TODO: Remove this function once application model is fully deprecated [APPLICATION] - a matching function which supports ComponentGroups is located in the snapshot package

func PrepareToRegisterIntegrationPipelineRunStarted

func PrepareToRegisterIntegrationPipelineRunStarted(snapshot *applicationapiv1alpha1.Snapshot)

PrepareToRegisterIntegrationPipelineRunStarted is to do preparation before calling RegisterPipelineRunStarted Don't use this function for PLR re-runs

func RemoveIntegrationTestRerunLabel

func RemoveIntegrationTestRerunLabel(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot) error

RemoveIntegrationTestRerunLabel removes re-run label from snapshot

func ResetSnapshotStatusConditions

func ResetSnapshotStatusConditions(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, message string) error

func SetAnnotationAndLabelForGroupSnapshot

func SetAnnotationAndLabelForGroupSnapshot(groupSnapshot *applicationapiv1alpha1.Snapshot, componentSnapshot *applicationapiv1alpha1.Snapshot, componentSnapshotInfos []ComponentSnapshotInfo) (*applicationapiv1alpha1.Snapshot, error)

func SetOwnerReference

func SetOwnerReference(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, owner *v1beta2.ComponentGroup) (*applicationapiv1alpha1.Snapshot, error)

SetOwnerReference sets the ComponentGroup as an owner of the snapshot

func SetOwnerReferenceApplication

func SetOwnerReferenceApplication(ctx context.Context, adapterClient client.Client, snapshot *applicationapiv1alpha1.Snapshot, owner *applicationapiv1alpha1.Application) (*applicationapiv1alpha1.Snapshot, error)

TODO: delete when we remove old application-specific code

func SetParentSnapshotsCreatedCondition

func SetParentSnapshotsCreatedCondition(snapshot *applicationapiv1alpha1.Snapshot, status metav1.ConditionStatus, reason, message string)

func SetSnapshotIntegrationStatusAsError

func SetSnapshotIntegrationStatusAsError(snapshot *applicationapiv1alpha1.Snapshot, message string)

SetSnapshotIntegrationStatusAsError sets the AppStudio integration status condition for the Snapshot to error.

func SetSnapshotIntegrationStatusAsInvalid

func SetSnapshotIntegrationStatusAsInvalid(snapshot *applicationapiv1alpha1.Snapshot, message string)

SetSnapshotIntegrationStatusAsInvalid sets the AppStudio integration status condition for the Snapshot to invalid.

func SnapshotIntegrationTestRerunTriggerPredicate

func SnapshotIntegrationTestRerunTriggerPredicate() predicate.Predicate

SnapshotIntegrationTestRerunTriggerPredicate returns a predicate which filters out all objects except when label for rerunning an integration test is added.

func SnapshotTestAnnotationChangePredicate

func SnapshotTestAnnotationChangePredicate() predicate.Predicate

SnapshotTestAnnotationChangePredicate returns a predicate which filters out all objects except when Snapshot annotation "test.appstudio.openshift.io/status" is changed for update events.

func SortSnapshots

SortSnapshots sorts the snapshots according to the snapshot annotation BuildPipelineRunStartTime

func UpdateComponentImageAndSource

func UpdateComponentImageAndSource(ctx context.Context, adapterClient client.Client, object client.Object, component *applicationapiv1alpha1.Component, componentSource applicationapiv1alpha1.ComponentSource, containerImage string) error

UpdateComponentImageAndSource updates both .Status.LastPromotedImage and .Status.LastBuiltCommit for a component resulting in updating the GCL, as well as annotation test.appstudio.openshift.io/lastbuilttime according to build plr's start time or current time for override snapshot

func ValidateImageDigest

func ValidateImageDigest(imageUrl string) error

ValidateImageDigest checks if image url contains valid digest, return error if check fails

func WriteIntegrationTestStatusesIntoSnapshot

func WriteIntegrationTestStatusesIntoSnapshot(ctx context.Context, s *applicationapiv1alpha1.Snapshot, sts *intgteststat.SnapshotIntegrationTestStatuses, c client.Client) error

WriteIntegrationTestStatusesIntoSnapshot writes data to snapshot by updating CR Data are written only when new changes are detected

Types

type AddedToGlobalCandidateListStatus

type AddedToGlobalCandidateListStatus struct {
	// Result for AddedToGlobalCandidateList
	Result bool `json:"result"`
	// Reason for AddedToGlobalCandidateList result
	Reason string `json:"reason"`
	// LastUpdatedTime for AddedToGlobalCandidateList
	LastUpdatedTime string `json:"lastupdatedtime"`
}

AddedToGlobalCandidateListStatus contains the information which will be added to build PLR or override snapshot about updating GCL

type ComponentSnapshotInfo

type ComponentSnapshotInfo struct {
	// Namespace
	Namespace string `json:"namespace"`
	// Component name
	Component string `json:"component"`
	// The build PLR name building the container image triggered by pull request
	BuildPipelineRun string `json:"buildPipelineRun"`
	// The built component snapshot from build PLR
	Snapshot string `json:"snapshot"`
	// The repo url for each component
	RepoUrl string `json:"repoUrl"`
	// Pull/Merge request number for updated component
	PullRequestNumber string `json:"pullRequestNumber"`
	// Version of the component
	Version string `json:"version"`
}

ComponentSnapshotInfo contains data about the component snapshots' info in group snapshot

func UnmarshalJSON

func UnmarshalJSON(b []byte) ([]*ComponentSnapshotInfo, error)

UnmarshalJSON load data from JSON

Jump to

Keyboard shortcuts

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