-
Notifications
You must be signed in to change notification settings - Fork 249
/
jobrun_locator_per_pr_jobs.go
59 lines (51 loc) · 1.89 KB
/
jobrun_locator_per_pr_jobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package jobrunaggregatorlib
import (
"time"
"github.com/sirupsen/logrus"
prowjobv1 "k8s.io/test-infra/prow/apis/prowjobs/v1"
)
const (
// ProwJobAggregationIDLabel is the name of the label for the aggregation id in prow job
ProwJobAggregationIDLabel = "release.openshift.io/aggregation-id"
// ProwJobPayloadInvocationIDLabel is the name of the label for the payload invocation id in prow job
ProwJobPayloadInvocationIDLabel = "release.openshift.io/aggregation-id"
// prowJobReleaseJobNameAnnotation refers to the original periodic job name for PR based payload runs.
// This is a special case for the PR invoked payload jobs where ProwJobJobNameAnnotation annotation
// refers to a uniquely generated name per job run. Thus, prowJobReleaseJobNameAnnotation is used to
// refer to the original job name.
prowJobReleaseJobNameAnnotation = "releaseJobName"
)
func NewProwJobMatcherFuncForPR(matchJobName, matchID, matchLabel string) ProwJobMatcherFunc {
return func(prowJob *prowjobv1.ProwJob) bool {
id := prowJob.Labels[matchLabel]
jobName := prowJob.Annotations[ProwJobJobNameAnnotation]
jobRunId := prowJob.Labels[prowJobJobRunIDLabel]
if releaseJobName, ok := prowJob.Annotations[prowJobReleaseJobNameAnnotation]; ok {
if releaseJobName != matchJobName {
return false
}
} else {
return false
}
logrus.Infof(" checking %v/%v for matchID match: looking for %q found %q.", jobName, jobRunId, matchID, id)
idMatches := len(matchID) > 0 && id == matchID
return idMatches
}
}
func NewPayloadAnalysisJobLocatorForPR(
jobName, matchID, matchLabel string,
startTime time.Time,
ciDataClient AggregationJobClient,
ciGCSClient CIGCSClient,
gcsBucketName string,
gcsPrefix string) JobRunLocator {
return NewPayloadAnalysisJobLocator(
jobName,
NewProwJobMatcherFuncForPR(jobName, matchID, matchLabel),
startTime,
ciDataClient,
ciGCSClient,
gcsBucketName,
gcsPrefix,
)
}