-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathtypes.go
More file actions
785 lines (680 loc) · 32.2 KB
/
types.go
File metadata and controls
785 lines (680 loc) · 32.2 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
package releasecontroller
import (
"fmt"
"slices"
"sync"
"time"
"github.com/openshift/release-controller/pkg/releasequalifiers"
"github.com/openshift/release-controller/pkg/utils"
"github.com/opencontainers/go-digest"
imagev1 "github.com/openshift/api/image/v1"
citools "github.com/openshift/ci-tools/pkg/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)
// APITag contains information about a release tag in a stream.
type APITag struct {
// Name is the name of the tag. This is usually a semantic version.
Name string `json:"name"`
// Phase is the phase of the tag.
Phase string `json:"phase"`
// PullSpec can be used to retrieve the release image.
PullSpec string `json:"pullSpec"`
// DownloadURL is a link to the web page for downloading the tools.
DownloadURL string `json:"downloadURL"`
}
// APIRelease contains information about a release stream.
type APIRelease struct {
// Name is the name of the release stream.
Name string `json:"name"`
// Tags is a list of all tags in the release sorted by semantic version, oldest to newest.
Tags []APITag `json:"tags"`
}
// APIReleaseInfo encapsulates the release verification results and upgrade history for a release tag.
type APIReleaseInfo struct {
// Name is the name of the release tag.
Name string `json:"name"`
// Phase is the phase of the release tag.
Phase string `json:"phase"`
// Results is the status of the release verification jobs for this release tag
Results *VerificationJobsSummary `json:"results,omitempty"`
// UpgradesTo is the list of UpgradeHistory "to" this release tag
UpgradesTo []UpgradeHistory `json:"upgradesTo,omitempty"`
//UpgradesFrom is the list of UpgradeHistory "from" this release tag
UpgradesFrom []UpgradeHistory `json:"upgradesFrom,omitempty"`
//ChangeLog is the html representation of the changes included in this release tag
ChangeLog []byte `json:"changeLog,omitempty"`
//ChangeLogJson is the json representation of the changes included in this release tag
ChangeLogJson ChangeLog `json:"changeLogJson,omitempty"`
}
// Release holds information about the release used during processing.
type Release struct {
// Source is the image stream that the Config was loaded from and holds all
// images that will compose the release.
Source *imagev1.ImageStream
// Target is the image stream that the release tag will be pushed to. It is
// modified and updated during processing by this controller to allow multiple
// release modifications in a single 'sync' call.
Target *imagev1.ImageStream
// Config holds the release configuration parsed off of Source.
Config *ReleaseConfig
}
// ReleaseConfig is serialized in JSON as the release.openshift.io/config annotation
// on image streams that wish to have release payloads generated from them. It modifies
// how the release is calculated.
type ReleaseConfig struct {
// Name is a required field and is used to associate release tags back to the input.
Name string `json:"name"`
// Message is a markdown string that is injected at the top of the release listing
// to describe the purpose of this stream.
Message string `json:"message"`
// Hide indicates this release should be visually less important on the status pages.
Hide bool `json:"hide"`
// EndOfLife indicates this release stream should be no longer be monitored or
// displayed by the release-controller
EndOfLife bool `json:"endOfLife"`
// As defines what this image stream provides. The default value is "Integration"
// and the images in the image stream will be used to build payloads. An optional
// mode is "Stable" and tags are assumed to be release payloads that should be promoted
// and published elsewhere. When choosing Stable, a user will tag a candidate release
// image in as a new tag to this image stream and the controller will rebuild and
// update the image with the appropriate name, metadata, and content.
As string `json:"as"`
// To is the image stream where release tags will be created when the As field is
// Integration. This field is ignored when As is Stable.
To string `json:"to"`
// MaxUnreadyReleases blocks creating new releases if there are more than this many
// releases in non-terminal (Failed, Accepted, Rejected) states.
MaxUnreadyReleases int `json:"maxUnreadyReleases"`
// MinCreationIntervalSeconds controls how quickly multiple releases can be created.
// Releases will be created no more rapidly than this interval.
MinCreationIntervalSeconds int `json:"minCreationIntervalSeconds"`
// ReferenceMode describes how the release image will refer to the origin. If empty
// or 'public' images will be copied and no source location will be preserved. If
// `source` then the controller will attempt to keep the originating reference in place.
ReferenceMode string `json:"referenceMode"`
// PullSecretName is the name of a pull secret in the release job namespace to mount
// into the pod that will create the release. The secret must contain a single file
// config.json with a valid Docker auths array.
PullSecretName string `json:"pullSecretName"`
// MirrorPrefix is the prefix applied to the release mirror image stream. If unset,
// MirrorPrefix is the name of the source image stream + the date.
MirrorPrefix string `json:"mirrorPrefix"`
// OverrideCLIImage may be used to override the location where the CLI image is
// located for actions on this image stream. It is useful when a bug prevents a
// historical image from being used with newer functionality.
OverrideCLIImage string `json:"overrideCLIImage"`
// Expires is the amount of time as a golang duration before Accepted release tags
// should be expired and removed. If unset, tags are not expired.
Expires utils.Duration `json:"expires"`
// Splay is the maximum random offset as a golang duration applied to verification
// job start times. Each job is assigned a deterministic random delay in [0, splay)
// based on the payload tag and job name. This spreads out job launches to reduce the
// blast radius of transient infrastructure issues like registry outages. If unset,
// all jobs start immediately.
Splay utils.Duration `json:"splay,omitempty"`
// Verify is a map of short names to verification steps that must succeed before the
// release is Accepted. Failures for some job types will cause the release to be
// rejected.
Verify map[string]ReleaseVerification `json:"verify"`
// Periodic is a map of short names to verification steps that run based on a cron
// or interval timer.
Periodic map[string]ReleasePeriodic `json:"periodic"`
// Publish is a map of short names to publish steps that will be performed after
// the release is Accepted. Some publish steps are continuously maintained, others
// may only be performed once.
Publish map[string]ReleasePublish `json:"publish"`
// Check is a map of short names to check routines that report additional information
// about the health or quality of this stream to the user interface.
Check map[string]ReleaseCheck `json:"check"`
// Upgrade is a map of short names of upgrade tests to launch for releases after they
// have been promoted into a "Stable" stream.
Upgrade map[string]UpgradeVerification `json:"upgrade"`
// AlternateImageRepository is the full path to an external Image Repository where we
// will mirror Accepted releases to.
// For example:
// "alternateImageRepository": "quay.io/openshift-release-dev/dev-release"
AlternateImageRepository string `json:"alternateImageRepository"`
// AlternateImageRepositorySecret is the name of the secret containing credentials to the
// alternate image repository. Secret must exist in job namespace. The secret must contain
// a single file config.json with a valid Docker auths array.
// For example:
// "alternateImageRepositorySecretName": "quay-openshift-release-dev-pull-secret"
AlternateImageRepositorySecretName string `json:"alternateImageRepositorySecretName"`
// DisableManifestListMode indicates this release stream should not utilize the --keep-manifest-list for release
// creation. This flag should NOT be used unless absolutely necessary...
// Currently, it's being added to work around a limitation with `oc` and images from konflux:
// https://issues.redhat.com/browse/OCPBUGS-50660
DisableManifestListMode bool `json:"disableManifestListMode"`
}
type ReleaseCheck struct {
// ConsistentImages verifies that the images in this release have not drifted
// significantly from the referenced parent and that no significant disparities
// exist.
ConsistentImages *CheckConsistentImages `json:"consistentImages"`
}
type CheckConsistentImages struct {
// Parent is the release stream to compare against.
Parent string `json:"parent"`
}
// ReleasePublish defines one action to take when a release is Accepted.
type ReleasePublish struct {
// Disabled will prevent this publish step from being run.
Disabled bool `json:"disabled"`
// TagRef updates the named tag in the release image stream to point at the release.
TagRef *PublishTagReference `json:"tagRef"`
// ImageStreamRef copies all images to another image stream in one transaction.
ImageStreamRef *PublishStreamReference `json:"imageStreamRef"`
// VerifyIssue marks jira issues fixed by this tag as VERIFIED in Jira if the QA contact reviewed and approved the bugfix PR
VerifyIssues *PublishVerifyIssues `json:"verifyIssues"`
}
// PublishTagReference ensures that the release image stream has a tag that points to
// the most recent release.
type PublishTagReference struct {
// Name is the name of the release image stream tag that will be updated to point to
// (reference) the release tag.
Name string `json:"name"`
}
// PublishStreamReference updates another image stream with spec tags that reference the
// images that were verified.
type PublishStreamReference struct {
// Name is the name of the release image stream to update. Required.
Name string `json:"name"`
// Namespace is the namespace of the release image stream to update. If left empty
// it will default to the same namespace as the release image stream.
Namespace string `json:"namespace"`
// Tags if set will limit the set of tags that are published.
Tags []string `json:"tags"`
// ExcludeTags if set will explicitly not publish these tags. Is applied after the
// tags field is checked.
ExcludeTags []string `json:"excludeTags"`
}
// PublishVerifyIssues marks jira issue fixed by this tag as VERIFIED in Jira if the QA contact reviewed and approved the bugfix PR
type PublishVerifyIssues struct {
// PreviousRelease points to the last release created before the imagestream
// being published was created. It is used to verify jira issues on the oldest tag
// in the release being published.
PreviousReleaseTag *VerifyIssuesTagInfo `json:"previousReleaseTag"`
}
// VerifyIssuesTagInfo contains the necessary data to get a tag reference as needed in the jira verification support.
type VerifyIssuesTagInfo struct {
// Namespace is the namespace where the imagestream resides.
Namespace string `json:"namespace"`
// Name is the name of the imagestream
Name string `json:"name"`
// Tag is the tag that is being referenced in the image stream
Tag string `json:"tag"`
}
// ReleaseVerification is a task that must be completed before a release is marked
// as Accepted. When some tasks fail the release will be marked as Rejected.
type ReleaseVerification struct {
// Disabled will prevent this verification from being considered as blocking
Disabled bool `json:"disabled"`
// Optional verifications are run, but failures will not cause the release to
// be rejected.
Optional bool `json:"optional"`
// Async, when set with Optional, means the release controller will not wait
// for this job to complete before accepting or rejecting the payload. The job
// will continue running after the payload reaches a terminal state.
Async bool `json:"async,omitempty"`
// Upgrade is true if this verification should be used to verify upgrades.
// The default UpgradeFrom for stable streams is PreviousMicro and the default
// for other types of streams is Previous.
Upgrade bool `json:"upgrade"`
// UpgradeFrom, if set, describes a different default upgrade source. The supported
// values are:
//
// Previous - selects the latest accepted tag from the current stream
// PreviousMinus1 - selects the second latest accepted tag from the current stream
// PreviousMicro - selects the latest accepted patch version from the current minor
// version (4.2.1 will select the latest accepted 4.2.z tag).
// PreviousMinor - selects the latest accepted patch version from the previous minor
// version (4.2.1 will select the latest accepted 4.1.z tag).
//
// If no matching target exists the job will be a no-op.
UpgradeFrom string `json:"upgradeFrom"`
// UpgradeFromRelease, if set, describes the release that should be used as the inital
// release in upgrade verification jobs.
UpgradeFromRelease *UpgradeRelease `json:"upgradeFromRelease"`
// ProwJob requires that the named ProwJob from the prow config pass before the
// release is accepted. The job is run only one time and if it fails the release
// is rejected.
ProwJob *ProwJobVerification `json:"prowJob"`
// Maximum retry attempts for the job. Defaults to 0 - do not retry on fail
MaxRetries int `json:"maxRetries,omitempty"`
// AggregatedProwJob defines the prow job used to run release analysis verification
AggregatedProwJob *AggregatedProwJobVerification `json:"aggregatedProwJob,omitempty"`
// MultiJobAnalysis indicates the job is used to analyze results from multiple other
// job runs from the payload. Thus, it needs some environment variables set, such as
// PAYLOAD_TAG.
MultiJobAnalysis bool `json:"multiJobAnalysis"`
// Qualifiers holds the releasequalifiers.ReleaseQualifiers definitions that enable,
// and override (if specified), any settings defined in:
// https://github.com/openshift/release/blob/master/core-services/release-controller/release-qualifiers.yaml
Qualifiers releasequalifiers.ReleaseQualifiers `json:"qualifiers,omitempty"`
}
// AggregatedProwJobVerification identifies the name of a prow job that will be used to
// aggregate the release analysis jobs.
type AggregatedProwJobVerification struct {
// ProwJob requires that the named ProwJob from the prow config pass before the
// release is accepted. The job is run only one time and if it fails the release
// is rejected.
// Defaults to "release-openshift-release-analysis-aggregator" if not specified.
ProwJob *ProwJobVerification `json:"prowJob,omitempty"`
// AnalysisJobCount Number of asynchronous jobs to execute for release analysis.
AnalysisJobCount int `json:"analysisJobCount,omitempty"`
}
// UpgradeVerification is an upgrade task that will be executed against releases, as
// they are promoted into a stable channel.
type UpgradeVerification struct {
// Disabled will prevent this verification from being used to launch any upgrade
// verification tests.
Disabled bool `json:"disabled"`
// ProwJob the name of the ProwJob, from prow's job configuration, that
// specifies the upgrade job definition to launch.
ProwJob *ProwJobVerification `json:"prowJob"`
}
// ReleasePeriodic is a job that runs on the speicifed cron or interval period as a
// release informer.
type ReleasePeriodic struct {
// Interval to wait between two runs of the job.
Interval string `json:"interval,omitempty"`
// Cron representation of job trigger time
Cron string `json:"cron,omitempty"`
// Upgrade is true if this periodic should be an upgrade job.
// The default UpgradeFrom for stable streams is PreviousMicro and the default
// for other types of streams is PreviousMinus1.
Upgrade bool `json:"upgrade"`
// UpgradeFrom, if set, describes a different default upgrade source. The supported
// values are:
//
// Previous - selects the latest accepted tag from the current stream
// PreviousMinus1 - selects the second latest accepted tag from the current stream
// PreviousMicro - selects the latest accepted patch version from the current minor
// version (4.2.1 will select the latest accepted 4.2.z tag).
// PreviousMinor - selects the latest accepted patch version from the previous minor
// version (4.2.1 will select the latest accepted 4.1.z tag).
//
// If no matching target exists the job will be a no-op.
UpgradeFrom string `json:"upgradeFrom"`
// UpgradeFromRelease, if set, describes the release that should be used as the inital
// release in upgrade periodic jobs.
UpgradeFromRelease *UpgradeRelease `json:"upgradeFromRelease"`
// ProwJob requires that the named ProwJob from the prow config pass before the
// release is accepted. The job is run only one time and if it fails the release
// is rejected.
ProwJob *ProwJobVerification `json:"prowJob"`
}
type UpgradeRelease struct {
// Candidate describes a candidate release payload
Candidate *UpgradeCandidate `json:"candidate,omitempty"`
// Prerelease describes a yet-to-be released payload
Prerelease *UpgradePrerelease `json:"prerelease,omitempty"`
// Official describes a released payload
Official *citools.Release `json:"release,omitempty"`
}
// UpgradeCandidate describes a validated candidate release payload
type UpgradeCandidate struct {
// Stream is the stream from which we pick the latest candidate
Stream string `json:"stream"`
// Version is the minor version to search for
Version string `json:"version"`
// Relative optionally specifies how old of a release
// is requested from this stream. For instance, a value
// of 1 will resolve to the previous validated release
// for this stream.
Relative int `json:"relative,omitempty"`
}
// UpgradePrerelease describes a validated release payload before it is exposed
type UpgradePrerelease struct {
// VersionBounds describe the allowable version bounds to search in
VersionBounds UpgradeVersionBounds `json:"version_bounds"`
}
// UpgradeVersionBounds describe the upper and lower bounds on a version search
type UpgradeVersionBounds struct {
Lower string `json:"lower"`
Upper string `json:"upper"`
}
func (b *UpgradeVersionBounds) Query() string {
return fmt.Sprintf(">%s <%s", b.Lower, b.Upper)
}
// ProwJobVerification identifies the name of a prow job that will be used to
// validate the release.
type ProwJobVerification struct {
// Name of the prow job to verify.
Name string `json:"name"`
}
type VerificationStatus struct {
State string `json:"state"`
URL string `json:"url"`
Retries int `json:"retries,omitempty"`
PreviousAttemptURLs []string `json:"previousAttemptURLs,omitempty"`
TransitionTime *metav1.Time `json:"transitionTime,omitempty"`
}
type VerificationStatusMap map[string]*VerificationStatus
// VerificationJobsSummary an organized, by job type, collection of VerificationStatusMap objects
type VerificationJobsSummary struct {
BlockingJobs VerificationStatusMap `json:"blockingJobs,omitempty"`
InformingJobs VerificationStatusMap `json:"informingJobs,omitempty"`
AsyncJobs VerificationStatusMap `json:"asyncJobs,omitempty"`
PendingJobs VerificationStatusMap `json:"pendingJobs,omitempty"`
}
type ReleasePromoteJobParameters struct {
// Parameters for promotion job described at
// https://github.com/openshift/aos-cd-jobs/blob/master/jobs/build/release/Jenkinsfile#L20-L81
// Imagestream tag which is to be promoted to the new release
FromTag string `json:"fromTag"`
// Name of new release to be created by the promote job
Name string `json:"name"`
// Optional: versions this can upgrade from
UpgradeFrom []string `json:"upgradeFrom,omitempty"`
}
type ReleaseCandidate struct {
ReleasePromoteJobParameters
CreationTime string `json:"creationTime,omitempty"`
Tag *imagev1.TagReference `json:"tag,omitempty"`
}
type ReleaseCandidateList struct {
Items []*ReleaseCandidate `json:"items"`
}
func (m VerificationStatusMap) Failures() ([]string, bool) {
var names []string
for name, s := range m {
if s.State == ReleaseVerificationStateFailed {
names = append(names, name)
}
}
return names, len(names) > 0
}
func (m VerificationStatusMap) Incomplete(required map[string]ReleaseVerification) ([]string, bool) {
var names []string
for name, definition := range required {
if definition.Disabled || definition.Async {
continue
}
if s, ok := m[name]; !ok || !slices.Contains([]string{ReleaseVerificationStateSucceeded, ReleaseVerificationStateFailed}, s.State) {
names = append(names, name)
}
}
return names, len(names) > 0
}
func VerificationJobsWithRetries(jobs map[string]ReleaseVerification, result VerificationStatusMap) ([]string, bool) {
var names []string
blockingJobFailure := false
for name, definition := range jobs {
if definition.Disabled || definition.Async {
continue
}
s, ok := result[name]
if !ok {
names = append(names, name)
continue
}
if !slices.Contains([]string{ReleaseVerificationStateFailed}, s.State) {
continue
}
if s.Retries >= definition.MaxRetries {
if !definition.Optional {
blockingJobFailure = true
}
continue
}
names = append(names, name)
}
return names, blockingJobFailure
}
func AllOptional(all map[string]ReleaseVerification, names ...string) bool {
for _, name := range names {
if v, ok := all[name]; ok && !v.Optional {
return false
}
}
return true
}
const (
// ReleasePhasePending is assigned to release tags that are waiting for an update
// payload image to be created and pushed.
//
// This phase may transition to Failed or Ready.
ReleasePhasePending = "Pending"
// ReleasePhaseFailed occurs when an update payload image cannot be created for
// a given set of image mirrors.
//
// This phase is a terminal phase. Pending is the only input phase.
ReleasePhaseFailed = "Failed"
// ReleasePhaseReady represents an image tag that has a valid update payload image
// created and pushed to the release image stream. It may not have completed all
// possible verification.
//
// This phase may transition to Accepted or Rejected. Pending is the only input phase.
ReleasePhaseReady = "Ready"
// ReleasePhaseAccepted represents an image tag that has passed its verification
// criteria and can safely be promoted to an external location.
//
// This phase is a terminal phase. Ready is the only input phase.
ReleasePhaseAccepted = "Accepted"
// ReleasePhaseRejected represents an image tag that has failed one or more of the
// verification criteria.
//
// The controller will take no more action in this phase, but a human may set the
// phase back to Ready to retry and the controller will attempt verification again.
ReleasePhaseRejected = "Rejected"
ReleaseVerificationStateSucceeded = "Succeeded"
ReleaseVerificationStateFailed = "Failed"
ReleaseVerificationStatePending = "Pending"
ReleaseConfigModeStable = "Stable"
ReleaseUpgradeFromPreviousMinor = "PreviousMinor"
ReleaseUpgradeFromPreviousPatch = "PreviousPatch"
ReleaseUpgradeFromPrevious = "Previous"
ReleaseUpgradeFromPreviousMinus1 = "PreviousMinus1"
// ReleaseAnnotationConfig is the JSON serialized representation of the ReleaseConfig
// struct. It is only accepted on image streams. An image stream with this annotation
// is considered an input image stream for creating releases.
ReleaseAnnotationConfig = "release.openshift.io/config"
ReleaseAnnotationKeep = "release.openshift.io/keep"
ReleaseAnnotationGeneration = "release.openshift.io/generation"
ReleaseAnnotationSource = "release.openshift.io/source"
ReleaseAnnotationTarget = "release.openshift.io/target"
ReleaseAnnotationName = "release.openshift.io/name"
ReleaseAnnotationReleaseTag = "release.openshift.io/releaseTag"
ReleaseAnnotationImageHash = "release.openshift.io/hash"
ReleaseAnnotationPhase = "release.openshift.io/phase"
ReleaseAnnotationCreationTimestamp = "release.openshift.io/creationTimestamp"
ReleaseAnnotationVerify = "release.openshift.io/verify"
// ReleaseAnnotationRewrite if true, the release controller should rewrite this release
ReleaseAnnotationRewrite = "release.openshift.io/rewrite"
// ReleaseAnnotationHasReleases an image stream with this annotation holds release tags
ReleaseAnnotationHasReleases = "release.openshift.io/hasReleases"
// ReleaseAnnotationMirrorImages if set, when rewriting a stable tag use the images locally
ReleaseAnnotationMirrorImages = "release.openshift.io/mirrorImages"
// ReleaseAnnotationJobPurpose when set on a job, controls which queue the job is notified on
ReleaseAnnotationJobPurpose = "release.openshift.io/purpose"
ReleaseAnnotationReason = "release.openshift.io/reason"
ReleaseAnnotationMessage = "release.openshift.io/message"
ReleaseAnnotationLog = "release.openshift.io/log"
ReleaseAnnotationFromTag = "release.openshift.io/from-tag"
ReleaseAnnotationToTag = "release.openshift.io/tag"
// ReleaseAnnotationFromImageStream specifies the imagestream
// a release was promoted from. It has the format <namespace>/<imagestream name>
ReleaseAnnotationFromImageStream = "release.openshift.io/from-image-stream"
// ReleaseAnnotationIssuesVerified indicates whether the release has been
// processed by the JiraVerifier
ReleaseAnnotationIssuesVerified = "release.openshift.io/issues-verified"
// ReleaseAnnotationSoftDelete indicates automation external to the release controller can use this annotation to decide when, formatted with RFC3339, to clean up the tag
ReleaseAnnotationSoftDelete = "release.openshift.io/soft-delete"
// ReleaseAnnotationArchitecture indicates the architecture of the release
ReleaseAnnotationArchitecture = "release.openshift.io/architecture"
// The following annotations are provided by ART and are intended to be carried forward from the input imagestream
// into the release-controller generated Release mirror.
// ReleaseAnnotationBuildURL the URL of the corresponding ART build that produced this Release
ReleaseAnnotationBuildURL = "release.openshift.io/build-url"
// ReleaseAnnotationRuntimeBrewEvent the Brew event number of the corresponding ART build that produced this Release
ReleaseAnnotationRuntimeBrewEvent = "release.openshift.io/runtime-brew-event"
// ReleaseAnnotationInconsistency an imagestream with this annotation indicates an inconsistency
ReleaseAnnotationInconsistency = "release.openshift.io/inconsistency"
// ReleaseLabelVerify indicates the ProwJob is for release verification
ReleaseLabelVerify = "release.openshift.io/verify"
// ReleaseLabelPayload indicates the ReleasePayload of the release
ReleaseLabelPayload = "release.openshift.io/payload"
// ProwJobResultsURLPrefix the URL prefix for ProwJob Results
ProwJobResultsURLPrefix = "https://prow.ci.openshift.org/view/gs/test-platform-results/logs"
// ProwJobLabelCapability adds a label to determine cluster for dispatcher/scheduler
ProwJobLabelCapability = "capability/rce"
// ReleaseStreamAnnotationMode specifies the mode that the stream is currently operating in
ReleaseStreamAnnotationMode = "release.openshift.io/mode"
// ReleaseStreamModeLocked specifies that the stream is currently locked
ReleaseStreamModeLocked = "locked"
// ReleaseStreamModeUnlocked specifies that the stream is currently unlocked
ReleaseStreamModeUnlocked = "unlocked"
// ReleaseStreamAnnotationMessagePrefix specifies an HTML string to inject before the ReleaseConfig.Message or ReleaseStreamAnnotationMessageOverride
ReleaseStreamAnnotationMessagePrefix = "release.openshift.io/messagePrefix"
// ReleaseStreamAnnotationMessageOverride overrides the message specified in ReleaseConfig.Message
ReleaseStreamAnnotationMessageOverride = "release.openshift.io/messageOverride"
)
// TagReferencesByAge returns the newest tag first, the oldest tag last
type TagReferencesByAge []*imagev1.TagReference
func (a TagReferencesByAge) Less(i, j int) bool {
return a[j].Annotations[ReleaseAnnotationCreationTimestamp] < a[i].Annotations[ReleaseAnnotationCreationTimestamp]
}
func (a TagReferencesByAge) Len() int { return len(a) }
func (a TagReferencesByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func CalculateBackoff(retryCount int, initialTime, currentTime *metav1.Time) time.Duration {
var backoffDuration time.Duration
if retryCount < 1 {
return backoffDuration
}
backoff := wait.Backoff{
Duration: time.Minute * 1,
Factor: 2,
Jitter: 0,
Steps: retryCount,
Cap: time.Minute * 15,
}
for backoff.Steps > 0 {
backoff.Step()
}
backoffDuration = backoff.Duration
if initialTime != nil {
backoffDuration += initialTime.Sub(currentTime.Time)
}
if backoffDuration < 0 {
backoffDuration = 0
}
return backoffDuration
}
func (in *ReleaseVerification) DeepCopy() *ReleaseVerification {
if in == nil {
return nil
}
out := new(ReleaseVerification)
in.DeepCopyInto(out)
return out
}
func (in *ReleaseVerification) DeepCopyInto(out *ReleaseVerification) {
*out = *in
if in.ProwJob != nil {
in, out := &in.ProwJob, &out.ProwJob
*out = new(ProwJobVerification)
(*in).DeepCopyInto(*out)
}
if in.AggregatedProwJob != nil {
in, out := &in.AggregatedProwJob, &out.AggregatedProwJob
*out = new(AggregatedProwJobVerification)
(*in).DeepCopyInto(*out)
}
}
func (in *ProwJobVerification) DeepCopyInto(out *ProwJobVerification) {
*out = *in
}
func (in *AggregatedProwJobVerification) DeepCopyInto(out *AggregatedProwJobVerification) {
*out = *in
if in.ProwJob != nil {
in, out := &in.ProwJob, &out.ProwJob
*out = new(ProwJobVerification)
(*in).DeepCopyInto(*out)
}
}
type UpgradeResult struct {
State string `json:"state"`
URL string `json:"url"`
}
type UpgradeRecord struct {
From string `json:"from"`
To string `json:"to"`
Results []UpgradeResult `json:"results"`
}
type UpgradeHistory struct {
From string
To string
Success int
Failure int
Total int
History map[string]UpgradeResult
}
// ChangeLog represents the data structure that oc returns when providing a changelog in JSON format
// TODO: This is being carried from changes in openshift/oc. These changes should be removed if/when we bump up our k8s dependencies up to the latest/greatest version. We're currently pinned at: v0.24.2
type ChangeLog struct {
From ChangeLogReleaseInfo `json:"from"`
To ChangeLogReleaseInfo `json:"to"`
Components []ChangeLogComponentInfo `json:"components,omitempty"`
NewImages []ChangeLogImageInfo `json:"newImages,omitempty"`
RemovedImages []ChangeLogImageInfo `json:"removedImages,omitempty"`
RebuiltImages []ChangeLogImageInfo `json:"rebuiltImages,omitempty"`
UpdatedImages []ChangeLogImageInfo `json:"updatedImages,omitempty"`
}
type ChangeLogReleaseInfo struct {
Name string `json:"name"`
Created time.Time `json:"created"`
Digest digest.Digest `json:"digest"`
PromotedFrom string `json:"promotedFrom,omitempty"`
}
type ChangeLogComponentInfo struct {
Name string `json:"name"`
Version string `json:"version"`
VersionUrl string `json:"versionUrl,omitempty"`
From string `json:"from,omitempty"`
FromUrl string `json:"fromUrl,omitempty"`
DiffUrl string `json:"diffUrl,omitempty"`
}
type ChangeLogImageInfo struct {
Name string `json:"name"`
Path string `json:"path"`
ShortCommit string `json:"shortCommit,omitempty"`
Commit string `json:"commit,omitempty"`
ImageRef string `json:"imageRef,omitempty"`
Commits []CommitInfo `json:"commits,omitempty"`
FullChangeLog string `json:"fullChangeLog,omitempty"`
}
type CommitInfo struct {
Bugs map[string]string `json:"bugs,omitempty"`
Issues map[string]string `json:"issues,omitempty"`
Subject string `json:"subject,omitempty"`
PullID int `json:"pullID,omitempty"`
PullURL string `json:"pullURL,omitempty"`
CommitID string `json:"commitID,omitempty"`
CommitURL string `json:"commitURL,omitempty"`
}
type APITagsBySemVerName []APITag
func (t APITagsBySemVerName) Less(i, j int) bool {
iVer, err := SemverParseTolerant(t[i].Name)
if err != nil {
return t[i].Name > t[j].Name
}
jVer, err := SemverParseTolerant(t[j].Name)
if err != nil {
return t[i].Name > t[j].Name
}
if iVer.GT(jVer) {
return true
}
if iVer.LT(jVer) {
return false
}
return t[i].Name > t[j].Name
}
func (t APITagsBySemVerName) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t APITagsBySemVerName) Len() int { return len(t) }
type ReleaseQualifiersConfig struct {
Qualifiers releasequalifiers.ReleaseQualifiers `yaml:"qualifiers"`
Mutex sync.RWMutex `yaml:"-"`
}