@@ -76,7 +76,7 @@ const (
7676 // SnapshotTestScenarioLabel contains the name of the Snapshot test scenario.
7777 SnapshotTestScenarioLabel = "test.appstudio.openshift.io/scenario"
7878
79- // SnapshotTestScenarioLabel contains json data with test results of the particular snapshot
79+ // SnapshotTestsStatusAnnotation contains json data with test results of the particular snapshot
8080 SnapshotTestsStatusAnnotation = "test.appstudio.openshift.io/status"
8181
8282 // (Deprecated) SnapshotPRLastUpdate contains timestamp of last time PR was updated
@@ -133,6 +133,9 @@ const (
133133 // ApplicationNameLabel contains the name of the application
134134 ApplicationNameLabel = AppstudioLabelPrefix + "/application"
135135
136+ // ComponentGroupNameLabel contains the name of the ComponentGroup
137+ ComponentGroupNameLabel = AppstudioLabelPrefix + "/component-group"
138+
136139 // SnapshotComponentType is the type of Snapshot which was created for a single component build.
137140 SnapshotComponentType = "component"
138141
@@ -227,10 +230,10 @@ const (
227230 // GitRefBranchPrefix is the git prefix denoting a reference is a branch
228231 GitRefBranchPrefix = "refs/heads/"
229232
230- //AppStudioTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
233+ // AppStudioTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
231234 AppStudioTestSucceededCondition = "AppStudioTestSucceeded"
232235
233- //LegacyTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
236+ // LegacyTestSucceededCondition is the condition for marking if the AppStudio Tests succeeded for the Snapshot.
234237 LegacyTestSucceededCondition = "HACBSStudioTestSucceeded"
235238
236239 // AppStudioIntegrationStatusCondition is the condition for marking the AppStudio integration status of the Snapshot.
@@ -244,7 +247,6 @@ const (
244247
245248 // SnapshotAddedToGlobalCandidateListCondition is the condition for marking if Snapshot's component was added to
246249 // the global candidate list.
247- // Checking statusCondition has been replaced by checking annotation test.appstudio.openshift.io/added-to-global-candidate-list now but this statusCondition is still kept
248250 SnapshotAddedToGlobalCandidateListCondition = "AddedToGlobalCandidateList"
249251
250252 // AppStudioTestSucceededConditionSatisfied is the reason that's set when the AppStudio tests succeed.
@@ -262,46 +264,46 @@ const (
262264 // AppStudioIntegrationStatusErrorOccured is the reason that's set when the AppStudio integration gets into an error state.
263265 AppStudioIntegrationStatusErrorOccured = "ErrorOccured"
264266
265- //AppStudioIntegrationStatusInProgress is the reason that's set when the AppStudio tests gets into an in progress state.
267+ // AppStudioIntegrationStatusInProgress is the reason that's set when the AppStudio tests gets into an in progress state.
266268 AppStudioIntegrationStatusInProgress = "InProgress"
267269
268- //AppStudioIntegrationStatusFinished is the reason that's set when the AppStudio tests finish.
270+ // AppStudioIntegrationStatusFinished is the reason that's set when the AppStudio tests finish.
269271 AppStudioIntegrationStatusFinished = "Finished"
270272
271- //AppStudioIntegrationStatusCancelled is the reason that's set when the AppStudio tests pipelinerun gets cancelled.
273+ // AppStudioIntegrationStatusCancelled is the reason that's set when the AppStudio tests pipelinerun gets cancelled.
272274 AppStudioIntegrationStatusCancelled = "CancelledRunFinally"
273275
274- // This annotation helps track PipelineRuns that were stopped before completion, enabling better auditability and observability .
276+ // PRGroupCancelledAnnotation helps track PipelineRuns that were stopped before completion.
275277 PRGroupCancelledAnnotation = PipelinesAsCodePrefix + "/cancelled"
276278
277- // the statuses needed to report to GiHub when creating check run or commit status, see doc
278- // https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-checks?apiVersion=2022-11-28
279- // https://docs.github.com/en/free-pro-team@latest/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run
280- //IntegrationTestStatusPendingGithub is the status reported to github when integration test is in a queue
279+ // IntegrationTestStatusPendingGithub is the status reported to github when integration test is in a queue
281280 IntegrationTestStatusPendingGithub = "pending"
282281
283- //IntegrationTestStatusSuccessGithub is the status reported to github when integration test succeed
282+ // IntegrationTestStatusSuccessGithub is the status reported to github when integration test succeed
284283 IntegrationTestStatusSuccessGithub = "success"
285284
286- //IntegrationTestStatusFailureGithub is the status reported to github when integration test fail
285+ // IntegrationTestStatusFailureGithub is the status reported to github when integration test fail
287286 IntegrationTestStatusFailureGithub = "failure"
288287
289- //IntegrationTestStatusErrorGithub is the status reported to github when integration test experience error
288+ // IntegrationTestStatusErrorGithub is the status reported to github when integration test experience error
290289 IntegrationTestStatusErrorGithub = "error"
291290
292- //IntegrationTestStatusInProgressGithub is the status reported to github when integration test is in progress
291+ // IntegrationTestStatusInProgressGithub is the status reported to github when integration test is in progress
293292 IntegrationTestStatusInProgressGithub = "in_progress"
294293
295- //IntegrationTestStatusCancelledGithub is the status reported to github when integration test is cancelled
294+ // IntegrationTestStatusCancelledGithub is the status reported to github when integration test is cancelled
296295 IntegrationTestStatusCancelledGithub = "cancelled"
297296
298- //IntegrationTestStatusNeutralGithub is the status reported to github when integration test is neutral
297+ // IntegrationTestStatusNeutralGithub is the status reported to github when integration test is neutral
299298 IntegrationTestStatusNeutralGithub = "neutral"
300299
300+ // ComponentNameForGroupSnapshot is the component name used for group snapshots
301301 ComponentNameForGroupSnapshot = "pr group"
302302
303+ // FailedToCreateGroupSnapshotMsg is the message when group snapshot creation fails
303304 FailedToCreateGroupSnapshotMsg = "Failed to create group snapshot for pr group"
304305
306+ // GroupSnapshotCreationFailureReported is the message when group snapshot creation failure is reported to git provider
305307 GroupSnapshotCreationFailureReported = "group snapshot creation failure is reported to git provider"
306308
307309 // Annotation that tells the integration service to skip checks for whether a build or snapshot is superseded
@@ -310,18 +312,11 @@ const (
310312 // PRStatusMerged indicates that the PR has been merged
311313 PRStatusMerged = "merged"
312314
315+ // Success is the success status value
313316 Success = "Success"
314- // AddedToGlobalCandidateListAnnotation is the annotation for marking if Snapshot/build PLR's component was added to
315- // the global candidate list.
316- AddedToGlobalCandidateListAnnotation = "test.appstudio.openshift.io/added-to-global-candidate-list"
317317
318- // maxPrefixLength is the maximum length of the prefix for the snapshot name
319- // When a suffix is used for collision handling, reduce by 3 to accommodate the 2-char suffix and extra dash
320- // Format: {prefix}-{YYYYMMDD}-{HHMMSS}-{mmm}[-{suffix}]
321- // Without suffix: 43 + 1 + 8 + 1 + 6 + 1 + 3 = 63 chars
322- // With suffix: 40 + 1 + 8 + 1 + 6 + 1 + 3 + 1 + 2 = 63 chars
323- maxPrefixLength = 43
324- maxPrefixLengthWithSuffix = 40 // 43 - 3 (2 for suffix + 1 for extra dash)
318+ // AddedToGlobalCandidateListAnnotation is the annotation for marking if Snapshot/build PLR's component was added to the global candidate list.
319+ AddedToGlobalCandidateListAnnotation = "test.appstudio.openshift.io/added-to-global-candidate-list"
325320
326321 // GitCommentPolicyAnnotation is the annotation to control git comment policy for the component
327322 GitCommentPolicyAnnotation = "test.appstudio.openshift.io/comment_strategy"
@@ -334,6 +329,16 @@ var (
334329 SnapshotComponentLabel = tektonconsts .ComponentNameLabel
335330)
336331
332+ const (
333+ // maxPrefixLength is the maximum length of the prefix for the snapshot name
334+ // When a suffix is used for collision handling, reduce by 3 to accommodate the 2-char suffix and extra dash
335+ // Format: {prefix}-{YYYYMMDD}-{HHMMSS}-{mmm}[-{suffix}]
336+ // Without suffix: 43 + 1 + 8 + 1 + 6 + 1 + 3 = 63 chars
337+ // With suffix: 40 + 1 + 8 + 1 + 6 + 1 + 3 + 1 + 2 = 63 chars
338+ maxPrefixLength = 43
339+ maxPrefixLengthWithSuffix = 40 // 43 - 3 (2 for suffix + 1 for extra dash)
340+ )
341+
337342// ComponentSnapshotInfo contains data about the component snapshots' info in group snapshot
338343type ComponentSnapshotInfo struct {
339344 // Namespace
@@ -827,7 +832,7 @@ func IsSnapshotCreatedByPACMergeQueueEvent(snapshot *applicationapiv1alpha1.Snap
827832}
828833
829834// IsSnapshotCreatedByPACPushEvent checks if a snapshot has label PipelineAsCodeEventTypeLabel and with push value
830- // it the label doesn't exist for some manual snapshot
835+ // if the label doesn't exist for some manual snapshot
831836func IsSnapshotCreatedByPACPushEvent (snapshot * applicationapiv1alpha1.Snapshot ) bool {
832837 return ! IsSnapshotCreatedByPACMergeQueueEvent (snapshot ) && ! IsGroupSnapshot (snapshot ) &&
833838 (metadata .HasLabelWithValue (snapshot , PipelineAsCodeEventTypeLabel , PipelineAsCodePushType ) ||
@@ -1135,7 +1140,9 @@ func ResetSnapshotStatusConditions(ctx context.Context, adapterClient client.Cli
11351140
11361141// CopySnapshotLabelsAndAnnotations coppies labels and annotations from build pipelineRun or tested snapshot
11371142// into regular snapshot
1138- func CopySnapshotLabelsAndAnnotations (application * applicationapiv1alpha1.Application , snapshot * applicationapiv1alpha1.Snapshot , componentName string , source * metav1.ObjectMeta , prefixes []string ) {
1143+ // ObjectMeta: metav1.ObjectMeta{
1144+ // TODO: replace 'object' with 'componentGroup' after application is deprecated. Also delete Application bool
1145+ func CopySnapshotLabelsAndAnnotations (object * metav1.ObjectMeta , snapshot * applicationapiv1alpha1.Snapshot , componentName string , source * metav1.ObjectMeta , prefixes []string , objectIsApplication bool ) {
11391146
11401147 if snapshot .Labels == nil {
11411148 snapshot .Labels = map [string ]string {}
@@ -1147,7 +1154,12 @@ func CopySnapshotLabelsAndAnnotations(application *applicationapiv1alpha1.Applic
11471154 snapshot .Labels [SnapshotTypeLabel ] = SnapshotComponentType
11481155
11491156 snapshot .Labels [SnapshotComponentLabel ] = componentName
1150- snapshot .Labels [ApplicationNameLabel ] = application .Name
1157+ if objectIsApplication {
1158+ snapshot .Labels [ApplicationNameLabel ] = object .Name
1159+ } else {
1160+ // the object is a ComponentGroup
1161+ snapshot .Labels [ComponentGroupNameLabel ] = object .Name
1162+ }
11511163
11521164 // Copy PAC annotations/labels from source(tested snapshot or pipelinerun) to snapshot.
11531165 _ = metadata .CopyLabelsWithPrefixReplacement (source , & snapshot .ObjectMeta , "pipelinesascode.tekton.dev" , PipelinesAsCodePrefix )
0 commit comments