-
Notifications
You must be signed in to change notification settings - Fork 250
/
types.go
2470 lines (2222 loc) · 98.4 KB
/
types.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
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
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package api
import (
"fmt"
"strings"
"k8s.io/apimachinery/pkg/util/sets"
prowv1 "k8s.io/test-infra/prow/apis/prowjobs/v1"
"k8s.io/test-infra/prow/repoowners"
)
const (
// PromotionJobLabelKey marks promotion jobs as such. Only its presence is
// relevant, its value is not.
PromotionJobLabelKey = "ci-operator.openshift.io/is-promotion"
)
// IsPromotionJob determines if a given ProwJob is a PromotionJob
func IsPromotionJob(jobLabels map[string]string) bool {
_, ok := jobLabels[PromotionJobLabelKey]
return ok
}
// ReleaseBuildConfiguration describes how release
// artifacts are built from a repository of source
// code. The configuration is made up of two parts:
// - minimal fields that allow the user to buy into
// our normal conventions without worrying about
// how the pipeline flows. Use these preferentially
// for new projects with simple/conventional build
// configurations.
// - raw steps that can be used to create custom and
// fine-grained build flows
type ReleaseBuildConfiguration struct {
Metadata Metadata `json:"zz_generated_metadata"`
InputConfiguration `json:",inline"`
// BinaryBuildCommands will create a "bin" image based on "src" that
// contains the output of this command. This allows reuse of binary artifacts
// across other steps. If empty, no "bin" image will be created.
BinaryBuildCommands string `json:"binary_build_commands,omitempty"`
// BinaryBuildCommandsList entries will create a "bin" image based on "src" that
// contains the output of this command. This allows reuse of binary artifacts
// across other steps. If empty, no "bin" image will be created.
// Mutually exclusive with BinaryBuildCommands
// DO NOT set this in the config
BinaryBuildCommandsList []RefCommands `json:"binary_build_commands_list,omitempty"`
// TestBinaryBuildCommands will create a "test-bin" image based on "src" that
// contains the output of this command. This allows reuse of binary artifacts
// across other steps. If empty, no "test-bin" image will be created.
TestBinaryBuildCommands string `json:"test_binary_build_commands,omitempty"`
// TestBinaryBuildCommandsList entries will create a "test-bin" image based on "src" that
// contains the output of this command. This allows reuse of binary artifacts
// across other steps. If empty, no "test-bin" image will be created.
// Mutually exclusive with TestBinaryBuildCommands
// DO NOT set this in the config
TestBinaryBuildCommandsList []RefCommands `json:"test_binary_build_commands_list,omitempty"`
// RpmBuildCommands will create an "rpms" image from "bin" (or "src", if no
// binary build commands were specified) that contains the output of this
// command. The created RPMs will then be served via HTTP to the "base" image
// via an injected rpm.repo in the standard location at /etc/yum.repos.d.
RpmBuildCommands string `json:"rpm_build_commands,omitempty"`
// RpmBuildCommandsList entries will create an "rpms" image from "bin" (or "src", if no
// binary build commands were specified) that contains the output of this
// command. The created RPMs will then be served via HTTP to the "base" image
// via an injected rpm.repo in the standard location at /etc/yum.repos.d.
// Mutually exclusive with RpmBuildCommands
// DO NOT set this in the config
RpmBuildCommandsList []RefCommands `json:"rpm_build_commands_list,omitempty"`
// RpmBuildLocation is where RPms are deposited after being built. If
// unset, this will default under the repository root to
// _output/local/releases/rpms/.
RpmBuildLocation string `json:"rpm_build_location,omitempty"`
// RpmBuildLocationList entries are where RPms are deposited after being built. If
// unset, this will default under the repository root to
// _output/local/releases/rpms/.
// Mutually exclusive with RpmBuildLocation
// DO NOT set this in the config
RpmBuildLocationList []RefLocation `json:"rpm_build_location_list,omitempty"`
// CanonicalGoRepository is a directory path that represents
// the desired location of the contents of this repository in
// Go. If specified the location of the repository we are
// cloning from is ignored.
CanonicalGoRepository *string `json:"canonical_go_repository,omitempty"`
// CanonicalGoRepositoryList is a directory path that represents
// the desired location of the contents of this repository in
// Go. If specified the location of the repository we are
// cloning from is ignored.
// Mutually exclusive with CanonicalGoRepository
// DO NOT set this in the config
CanonicalGoRepositoryList []RefRepository `json:"canonical_go_repository_list,omitempty"`
// Images describes the images that are built
// baseImage the project as part of the release
// process. The name of each image is its "to" value
// and can be used to build only a specific image.
Images []ProjectDirectoryImageBuildStepConfiguration `json:"images,omitempty"`
// Operator describes the operator bundle(s) that is built by the project
Operator *OperatorStepConfiguration `json:"operator,omitempty"`
// Tests describes the tests to run inside of built images.
// The images launched as pods but have no explicit access to
// the cluster they are running on.
Tests []TestStepConfiguration `json:"tests,omitempty"`
// RawSteps are literal Steps that should be
// included in the final pipeline.
RawSteps []StepConfiguration `json:"raw_steps,omitempty"`
// PromotionConfiguration determines how images are promoted
// by this command. It is ignored unless promotion has specifically
// been requested. Promotion is performed after all other steps
// have been completed so that tests can be run prior to promotion.
// If no promotion is defined, it is defaulted from the ReleaseTagConfiguration.
PromotionConfiguration *PromotionConfiguration `json:"promotion,omitempty"`
// Resources is a set of resource requests or limits over the
// input types. The special name '*' may be used to set default
// requests and limits.
Resources ResourceConfiguration `json:"resources,omitempty"`
}
// RefCommands pairs a ref (in org/repo format) with commands
type RefCommands struct {
Ref string `json:"ref"`
Commands string `json:"commands"`
}
// RefLocation pairs a ref (in org/repo format) with a location
type RefLocation struct {
Ref string `json:"ref"`
Location string `json:"location"`
}
// RefRepository pairs a ref (in org/repo format) with a repository
type RefRepository struct {
Ref string `json:"ref"`
Repository string `json:"repository"`
}
// Metadata describes the source repo for which a config is written
type Metadata struct {
Org string `json:"org"`
Repo string `json:"repo"`
Branch string `json:"branch"`
Variant string `json:"variant,omitempty"`
}
// BuildsImage checks if an image is built by the release configuration.
func (config ReleaseBuildConfiguration) BuildsImage(name string) bool {
for _, i := range config.Images {
if string(i.To) == name {
return true
}
}
return false
}
// IsBaseImage checks if `name` will be a tag in the pipeline image stream
// by virtue of being imported as a base image
func (config ReleaseBuildConfiguration) IsBaseImage(name string) bool {
for i := range config.BaseImages {
if i == name {
return true
}
}
for i := range config.BaseRPMImages {
if i == name {
return true
}
}
return false
}
// IsPipelineImage checks if `name` will be a tag in the pipeline image stream.
func (config ReleaseBuildConfiguration) IsPipelineImage(name string) bool {
if config.IsBaseImage(name) {
return true
}
if strings.HasPrefix(name, string(PipelineImageStreamTagReferenceRoot)) ||
strings.HasPrefix(name, string(PipelineImageStreamTagReferenceSource)) ||
strings.HasPrefix(name, string(PipelineImageStreamTagReferenceBinaries)) ||
strings.HasPrefix(name, string(PipelineImageStreamTagReferenceTestBinaries)) ||
strings.HasPrefix(name, string(PipelineImageStreamTagReferenceRPMs)) ||
strings.HasPrefix(name, string(PipelineImageStreamTagReferenceBundleSource)) {
return true
}
if IsIndexImage(name) {
return true
}
return config.IsBundleImage(name)
}
// ResourceConfiguration defines resource overrides for jobs run
// by the operator.
type ResourceConfiguration map[string]ResourceRequirements
func (c ResourceConfiguration) RequirementsForStep(name string) ResourceRequirements {
req := ResourceRequirements{
Requests: make(ResourceList),
Limits: make(ResourceList),
}
if defaults, ok := c["*"]; ok {
req.Requests.Add(defaults.Requests)
req.Limits.Add(defaults.Limits)
}
if values, ok := c[name]; ok {
req.Requests.Add(values.Requests)
req.Limits.Add(values.Limits)
}
return req
}
// ResourceRequirements are resource requests and limits applied
// to the individual steps in the job. They are passed directly to
// builds or pods.
type ResourceRequirements struct {
// Requests are resource requests applied to an individual step in the job.
// These are directly used in creating the Pods that execute the Job.
Requests ResourceList `json:"requests,omitempty"`
// Limits are resource limits applied to an individual step in the job.
// These are directly used in creating the Pods that execute the Job.
Limits ResourceList `json:"limits,omitempty"`
}
// ResourceList is a map of string resource names and resource
// quantities, as defined on Kubernetes objects. Common resources
// to request or limit are `cpu` and `memory`. For `cpu`, values
// are provided in vCPUs - for instance, `2` or `200m`. For
// `memory`, values are provided in bytes - for instance, `20Mi`
// or `3Gi`.
type ResourceList map[string]string
func (l ResourceList) Add(values ResourceList) {
for name, value := range values {
l[name] = value
}
}
// InputConfiguration contains the set of image inputs
// to a build and can be used as an override to the
// canonical inputs by a local process.
type InputConfiguration struct {
// The list of base images describe
// which images are going to be necessary outside
// of the pipeline. The key will be the alias that other
// steps use to refer to this image.
BaseImages map[string]ImageStreamTagReference `json:"base_images,omitempty"`
// BaseRPMImages is a list of the images and their aliases that will
// have RPM repositories injected into them for downstream
// image builds that require built project RPMs.
BaseRPMImages map[string]ImageStreamTagReference `json:"base_rpm_images,omitempty"`
// BuildRootImage supports two ways to get the image that
// the pipeline will caches on. The one way is to take the reference
// from an image stream, and the other from a dockerfile.
BuildRootImage *BuildRootImageConfiguration `json:"build_root,omitempty"`
// BuildRootImages entries support two ways to get the image that
// the pipeline will caches on. The one way is to take the reference
// from an image stream, and the other from a dockerfile.
// Mutually exclusive with BuildRootImage
// DO NOT set this in the config
BuildRootImages map[string]BuildRootImageConfiguration `json:"build_roots,omitempty"`
// ReleaseTagConfiguration determines how the
// full release is assembled.
ReleaseTagConfiguration *ReleaseTagConfiguration `json:"tag_specification,omitempty"`
// Releases maps semantic release payload identifiers
// to the names that they will be exposed under. For
// instance, an 'initial' name will be exposed as
// $RELEASE_IMAGE_INITIAL. The 'latest' key is special
// and cannot co-exist with 'tag_specification', as
// they result in the same output.
Releases map[string]UnresolvedRelease `json:"releases,omitempty"`
}
// UnresolvedRelease describes a semantic release payload
// identifier we need to resolve to a pull spec.
type UnresolvedRelease struct {
// Integration describes an integration stream which we can create a payload out of
Integration *Integration `json:"integration,omitempty"`
// Candidate describes a candidate release payload
Candidate *Candidate `json:"candidate,omitempty"`
// Prerelease describes a yet-to-be released payload
Prerelease *Prerelease `json:"prerelease,omitempty"`
// Release describes a released payload
Release *Release `json:"release,omitempty"`
}
// Integration is an ImageStream holding the latest images from development builds of OCP.
type Integration struct {
// Namespace is the namespace in which the integration stream lives.
Namespace string `json:"namespace"`
// Name is the name of the ImageStream
Name string `json:"name"`
// IncludeBuiltImages determines if the release we assemble will include
// images built during the test itself.
IncludeBuiltImages bool `json:"include_built_images,omitempty"`
}
// ReleaseDescriptor holds common data for different types of release payloads
type ReleaseDescriptor struct {
// Product is the name of the product being released
Product ReleaseProduct `json:"product"`
// Architecture is the architecture for the product.
// Defaults to amd64.
Architecture ReleaseArchitecture `json:"architecture,omitempty"`
// 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"`
}
// Candidate describes a validated candidate release payload
type Candidate struct {
ReleaseDescriptor
// ReleaseStream is the stream from which we pick the latest candidate
Stream ReleaseStream `json:"stream"`
// Version is the minor version to search for
Version string `json:"version"`
}
// Prerelease describes a validated release payload before it is exposed
type Prerelease struct {
ReleaseDescriptor
// VersionBounds describe the allowable version bounds to search in
VersionBounds VersionBounds `json:"version_bounds"`
}
// VersionBounds describe the upper and lower bounds and stream on a version search
type VersionBounds struct {
Lower string `json:"lower"`
Upper string `json:"upper"`
// Stream dictates which stream to search for a version within the specified bounds
// defaults to 4-stable.
Stream string `json:"stream,omitempty"`
}
func (b *VersionBounds) Query() string {
return fmt.Sprintf(">%s <%s", b.Lower, b.Upper)
}
func BoundsFromQuery(query string) (*VersionBounds, error) {
splitParts := strings.Split(query, " ")
if len(splitParts) != 2 || !strings.HasPrefix(splitParts[0], ">") || !strings.HasPrefix(splitParts[1], "<") {
return nil, fmt.Errorf("Invalid version range `%s`. Must be in form `>4.x.y <4.a.b-c`", query)
}
return &VersionBounds{
Lower: strings.TrimPrefix(splitParts[0], ">"),
Upper: strings.TrimPrefix(splitParts[1], "<"),
}, nil
}
// ReleaseProduct describes the product being released
type ReleaseProduct string
const (
ReleaseProductOCP ReleaseProduct = "ocp"
ReleaseProductOKD ReleaseProduct = "okd"
)
// ReleaseArchitecture describes the architecture for the product
type ReleaseArchitecture string
const (
ReleaseArchitectureAMD64 ReleaseArchitecture = "amd64"
ReleaseArchitecturePPC64le ReleaseArchitecture = "ppc64le"
ReleaseArchitectureS390x ReleaseArchitecture = "s390x"
ReleaseArchitectureARM64 ReleaseArchitecture = "arm64"
ReleaseArchitectureMULTI ReleaseArchitecture = "multi" //heterogeneous payload
)
type ReleaseStream string
const (
ReleaseStreamCI ReleaseStream = "ci"
ReleaseStreamNightly ReleaseStream = "nightly"
ReleaseStreamOKD ReleaseStream = "okd"
ReleaseStreamOKDScos ReleaseStream = "okd-scos"
)
// Release describes a generally available release payload
type Release struct {
// Version is the minor version to search for
Version string `json:"version"`
// Channel is the release channel to search in
Channel ReleaseChannel `json:"channel"`
// Architecture is the architecture for the release.
// Defaults to amd64.
Architecture ReleaseArchitecture `json:"architecture,omitempty"`
}
type ReleaseChannel string
const (
ReleaseChannelStable ReleaseChannel = "stable"
ReleaseChannelFast ReleaseChannel = "fast"
ReleaseChannelCandidate ReleaseChannel = "candidate"
// CIOperatorInrepoConfigFileName is the name of the file that contains the build root images
// pullspec.
CIOperatorInrepoConfigFileName = ".ci-operator.yaml"
)
type CIOperatorInrepoConfig struct {
BuildRootImage ImageStreamTagReference `json:"build_root_image"`
}
// BuildRootImageConfiguration holds the two ways of using a base image
// that the pipeline will caches on.
type BuildRootImageConfiguration struct {
ImageStreamTagReference *ImageStreamTagReference `json:"image_stream_tag,omitempty"`
ProjectImageBuild *ProjectDirectoryImageBuildInputs `json:"project_image,omitempty"`
// If the BuildRoot images pullspec should be read from a file in the repository (BuildRootImageFileName).
FromRepository bool `json:"from_repository,omitempty"`
// UseBuildCache enables the import and use of the prior `bin` image
// as a build cache, if the underlying build root has not changed since
// the previous cache was published.
UseBuildCache bool `json:"use_build_cache,omitempty"`
}
// ImageStreamTagReference identifies an ImageStreamTag
type ImageStreamTagReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Tag string `json:"tag"`
// As is an optional string to use as the intermediate name for this reference.
As string `json:"as,omitempty"`
}
func (i *ImageStreamTagReference) ISTagName() string {
return fmt.Sprintf("%s/%s:%s", i.Namespace, i.Name, i.Tag)
}
// ReleaseTagConfiguration describes how a release is
// assembled from release artifacts. A release image stream is a
// single stream with multiple tags (openshift/origin-v3.9:control-plane),
// each tag being a unique and well defined name for a component.
type ReleaseTagConfiguration struct {
// Namespace identifies the namespace from which
// all release artifacts not built in the current
// job are tagged from.
Namespace string `json:"namespace"`
// Name is the image stream name to use that contains all
// component tags.
Name string `json:"name"`
// IncludeBuiltImages determines if the release we assemble will include
// images built during the test itself.
IncludeBuiltImages bool `json:"include_built_images,omitempty"`
}
func (config ReleaseTagConfiguration) InputsName() string {
return "[release-inputs]"
}
func (config ReleaseTagConfiguration) TargetName(name string) string {
return fmt.Sprintf("[release:%s]", name)
}
// ReleaseConfiguration records a resolved release with its name.
// We always expect this step to be preempted with an env var
// that was set at startup. This will be cleaner when we refactor
// release dependencies.
type ReleaseConfiguration struct {
Name string `json:"name"`
UnresolvedRelease `json:",inline"`
}
func (config ReleaseConfiguration) TargetName() string {
return fmt.Sprintf("[release:%s]", config.Name)
}
// PromotionConfiguration describes where images created by this
// config should be published to. The release tag configuration
// defines the inputs, while this defines the outputs.
type PromotionConfiguration struct {
// Targets configure a set of images to be pushed to
// a registry.
Targets []PromotionTarget `json:"to,omitempty"`
// RegistryOverride is an override for the registry domain to
// which we will mirror images. This is an advanced option and
// should *not* be used in common test workflows. The CI chat
// bot uses this option to facilitate image sharing.
RegistryOverride string `json:"registry_override,omitempty"`
// DisableBuildCache stops us from uploading the build cache.
// This is useful (only) for CI chat bot invocations where
// promotion does not imply output artifacts are being created
// for posterity.
DisableBuildCache bool `json:"disable_build_cache,omitempty"`
}
type PromotionTarget struct {
// Namespace identifies the namespace to which the built
// artifacts will be published to.
Namespace string `json:"namespace"`
// Name is an optional image stream name to use that
// contains all component tags. If specified, tag is
// ignored.
Name string `json:"name,omitempty"`
// Tag is the ImageStreamTag tagged in for each
// build image's ImageStream.
Tag string `json:"tag,omitempty"`
// TagByCommit determines if an image should be tagged by the
// git commit that was used to build it. If Tag is also set,
// this will cause both a floating tag and commit-specific tags
// to be promoted.
TagByCommit bool `json:"tag_by_commit,omitempty"`
// ExcludedImages are image names that will not be promoted.
// Exclusions are made before additional_images are included.
// Use exclusions when you want to build images for testing
// but not promote them afterwards.
ExcludedImages []string `json:"excluded_images,omitempty"`
// AdditionalImages is a mapping of images to promote. The
// images will be taken from the pipeline image stream. The
// key is the name to promote as and the value is the source
// name. If you specify a tag that does not exist as the source
// the destination tag will not be created.
AdditionalImages map[string]string `json:"additional_images,omitempty"`
// Disabled will no-op succeed instead of running the actual
// promotion step. This is useful when two branches need to
// promote to the same output imagestream on a cut-over but
// never concurrently, and you want to have promotion config
// in the ci-operator configuration files all the time.
Disabled bool `json:"disabled,omitempty"`
}
// StepConfiguration holds one step configuration.
// Only one of the fields in this can be non-null.
type StepConfiguration struct {
InputImageTagStepConfiguration *InputImageTagStepConfiguration `json:"input_image_tag_step,omitempty"`
PipelineImageCacheStepConfiguration *PipelineImageCacheStepConfiguration `json:"pipeline_image_cache_step,omitempty"`
SourceStepConfiguration *SourceStepConfiguration `json:"source_step,omitempty"`
BundleSourceStepConfiguration *BundleSourceStepConfiguration `json:"bundle_source_step,omitempty"`
IndexGeneratorStepConfiguration *IndexGeneratorStepConfiguration `json:"index_generator_step,omitempty"`
ProjectDirectoryImageBuildStepConfiguration *ProjectDirectoryImageBuildStepConfiguration `json:"project_directory_image_build_step,omitempty"`
RPMImageInjectionStepConfiguration *RPMImageInjectionStepConfiguration `json:"rpm_image_injection_step,omitempty"`
RPMServeStepConfiguration *RPMServeStepConfiguration `json:"rpm_serve_step,omitempty"`
OutputImageTagStepConfiguration *OutputImageTagStepConfiguration `json:"output_image_tag_step,omitempty"`
ReleaseImagesTagStepConfiguration *ReleaseTagConfiguration `json:"release_images_tag_step,omitempty"`
ResolvedReleaseImagesStepConfiguration *ReleaseConfiguration `json:"resolved_release_images_step,omitempty"`
TestStepConfiguration *TestStepConfiguration `json:"test_step,omitempty"`
ProjectDirectoryImageBuildInputs *ProjectDirectoryImageBuildInputs `json:"project_directory_image_build_inputs,omitempty"`
}
// InputImageTagStepConfiguration describes a step that
// tags an externalImage image in to the build pipeline.
// if no explicit output tag is provided, the name
// of the image is used as the tag.
type InputImageTagStepConfiguration struct {
InputImage `json:",inline"`
Sources []ImageStreamSource `json:"-"`
}
func (config InputImageTagStepConfiguration) TargetName() string {
return fmt.Sprintf("[input:%s]", config.To)
}
func (config InputImageTagStepConfiguration) Matches(other InputImage) bool {
return config.InputImage == other
}
func (config InputImageTagStepConfiguration) FormattedSources() string {
var formattedSources []string
tests := sets.Set[string]{}
for _, source := range config.Sources {
switch source.SourceType {
case ImageStreamSourceTest:
tests.Insert(source.Name)
default:
item := string(source.SourceType)
if source.Name != "" {
item += ": " + source.Name
}
formattedSources = append(formattedSources, item)
}
}
if len(tests) > 0 {
formattedSources = append(formattedSources, fmt.Sprintf("test steps: %s", strings.Join(sets.List(tests), ",")))
}
return strings.Join(formattedSources, "|")
}
func (config *InputImageTagStepConfiguration) AddSources(sources ...ImageStreamSource) {
config.Sources = append(config.Sources, sources...)
}
type InputImage struct {
BaseImage ImageStreamTagReference `json:"base_image"`
To PipelineImageStreamTagReference `json:"to,omitempty"`
// Ref is an optional string linking to the extra_ref in "org.repo" format that this belongs to
Ref string `json:"ref,omitempty"`
}
type ImageStreamSourceType string
const (
ImageStreamSourceRoot ImageStreamSourceType = "root"
ImageStreamSourceBase ImageStreamSourceType = "base_image"
ImageStreamSourceBaseRpm ImageStreamSourceType = "base_rpm_image"
ImageStreamSourceTest ImageStreamSourceType = "test step"
)
type ImageStreamSource struct {
SourceType ImageStreamSourceType
Name string
}
// OutputImageTagStepConfiguration describes a step that
// tags a pipeline image out from the build pipeline.
type OutputImageTagStepConfiguration struct {
From PipelineImageStreamTagReference `json:"from"`
To ImageStreamTagReference `json:"to"`
// Optional means the output step is not built, published, or
// promoted unless explicitly targeted. Use for builds which
// are invoked only when testing certain parts of the repo.
Optional bool `json:"optional"`
}
func (config OutputImageTagStepConfiguration) TargetName() string {
if len(config.To.As) == 0 {
return fmt.Sprintf("[output:%s:%s]", config.To.Name, config.To.Tag)
}
return config.To.As
}
// PipelineImageCacheStepConfiguration describes a
// step that builds a container image to cache the
// output of commands.
type PipelineImageCacheStepConfiguration struct {
From PipelineImageStreamTagReference `json:"from"`
To PipelineImageStreamTagReference `json:"to"`
// Commands are the shell commands to run in
// the repository root to create the cached
// content.
Commands string `json:"commands"`
// Ref is an optional string linking to the extra_ref in "org.repo" format that this belongs to
Ref string `json:"ref,omitempty"`
}
func (config PipelineImageCacheStepConfiguration) TargetName() string {
return string(config.To)
}
// Cluster is the name of a cluster in CI build farm.
type Cluster string
const (
ClusterAPPCI Cluster = "app.ci"
ClusterBuild01 Cluster = "build01"
ClusterBuild02 Cluster = "build02"
ClusterBuild03 Cluster = "build03"
ClusterBuild10 Cluster = "build10"
ClusterVSphere02 Cluster = "vsphere02"
ClusterARM01 Cluster = "arm01"
ClusterHive Cluster = "hosted-mgmt"
)
// TestStepConfiguration describes a step that runs a
// command in one of the previously built images and then
// gathers artifacts from that step.
type TestStepConfiguration struct {
// As is the name of the test.
As string `json:"as"`
// Commands are the shell commands to run in
// the repository root to execute tests.
Commands string `json:"commands,omitempty"`
// Cluster specifies the name of the cluster where the test runs.
Cluster Cluster `json:"cluster,omitempty"`
// Secret is an optional secret object which
// will be mounted inside the test container.
// You cannot set the Secret and Secrets attributes
// at the same time.
Secret *Secret `json:"secret,omitempty"`
// Secrets is an optional array of secret objects
// which will be mounted inside the test container.
// You cannot set the Secret and Secrets attributes
// at the same time.
Secrets []*Secret `json:"secrets,omitempty"`
// Cron is how often the test is expected to run outside
// of pull request workflows. Setting this field will
// create a periodic job instead of a presubmit
Cron *string `json:"cron,omitempty"`
// Presubmit configures prowgen to generate a presubmit job in additional to the periodic job.
// It can be used only when the test itself is a periodic job.
Presubmit bool `json:"presubmit,omitempty"`
// Interval is how frequently the test should be run based
// on the last time the test ran. Setting this field will
// create a periodic job instead of a presubmit
Interval *string `json:"interval,omitempty"`
// MinimumInterval to wait between two runs of the job. Consecutive
// jobs are run at `minimum_interval` + `duration of previous job`
// apart. Setting this field will create a periodic job instead of a
// presubmit
MinimumInterval *string `json:"minimum_interval,omitempty"`
// ReleaseController configures prowgen to create a periodic that
// does not get run by prow and instead is run by release-controller.
// The job must be configured as a verification or periodic job in a
// release-controller config file when this field is set to `true`.
ReleaseController bool `json:"release_controller,omitempty"`
// Postsubmit configures prowgen to generate the job as a postsubmit rather than a presubmit
Postsubmit bool `json:"postsubmit,omitempty"`
// ClusterClaim claims an OpenShift cluster and exposes environment variable ${KUBECONFIG} to the test container
ClusterClaim *ClusterClaim `json:"cluster_claim,omitempty"`
// AlwaysRun can be set to false to disable running the job on every PR
AlwaysRun *bool `json:"always_run,omitempty"`
// RunIfChanged is a regex that will result in the test only running if something that matches it was changed.
RunIfChanged string `json:"run_if_changed,omitempty"`
// PipelineRunIfChanged is a regex that will result in the test only running in second
// stage of the pipeline run if something that matches it was changed.
PipelineRunIfChanged string `json:"pipeline_run_if_changed,omitempty"`
// Optional indicates that the job's status context, that is generated from the corresponding test, should not be required for merge.
Optional bool `json:"optional,omitempty"`
// Portable allows to port periodic tests to current and future release despite the demand to skip periodics
Portable bool `json:"portable,omitempty"`
// SkipIfOnlyChanged is a regex that will result in the test being skipped if all changed files match that regex.
SkipIfOnlyChanged string `json:"skip_if_only_changed,omitempty"`
// Timeout overrides maximum prowjob duration
Timeout *prowv1.Duration `json:"timeout,omitempty"`
// Only one of the following can be not-null.
ContainerTestConfiguration *ContainerTestConfiguration `json:"container,omitempty"`
MultiStageTestConfiguration *MultiStageTestConfiguration `json:"steps,omitempty"`
MultiStageTestConfigurationLiteral *MultiStageTestConfigurationLiteral `json:"literal_steps,omitempty"`
OpenshiftAnsibleClusterTestConfiguration *OpenshiftAnsibleClusterTestConfiguration `json:"openshift_ansible,omitempty"`
OpenshiftAnsibleSrcClusterTestConfiguration *OpenshiftAnsibleSrcClusterTestConfiguration `json:"openshift_ansible_src,omitempty"`
OpenshiftAnsibleCustomClusterTestConfiguration *OpenshiftAnsibleCustomClusterTestConfiguration `json:"openshift_ansible_custom,omitempty"`
OpenshiftInstallerClusterTestConfiguration *OpenshiftInstallerClusterTestConfiguration `json:"openshift_installer,omitempty"`
OpenshiftInstallerUPIClusterTestConfiguration *OpenshiftInstallerUPIClusterTestConfiguration `json:"openshift_installer_upi,omitempty"`
OpenshiftInstallerUPISrcClusterTestConfiguration *OpenshiftInstallerUPISrcClusterTestConfiguration `json:"openshift_installer_upi_src,omitempty"`
OpenshiftInstallerCustomTestImageClusterTestConfiguration *OpenshiftInstallerCustomTestImageClusterTestConfiguration `json:"openshift_installer_custom_test_image,omitempty"`
}
func (config TestStepConfiguration) TargetName() string {
return config.As
}
func (config TestStepConfiguration) IsPeriodic() bool {
return config.Interval != nil || config.MinimumInterval != nil || config.Cron != nil || config.ReleaseController
}
// Cloud is the name of a cloud provider, e.g., aws cluster topology, etc.
type Cloud string
const (
CloudAWS Cloud = "aws"
CloudGCP Cloud = "gcp"
CloudAzure4 Cloud = "azure4"
CloudVSphere Cloud = "vsphere"
)
// ClusterClaim claims an OpenShift cluster for the job.
type ClusterClaim struct {
// As is the name to use when importing the cluster claim release payload.
// If unset, claim release will be imported as `latest`.
As string `json:"as,omitempty"`
// Product is the name of the product being released.
// Defaults to ocp.
Product ReleaseProduct `json:"product,omitempty"`
// Version is the version of the product
Version string `json:"version"`
// Architecture is the architecture for the product.
// Defaults to amd64.
Architecture ReleaseArchitecture `json:"architecture,omitempty"`
// Cloud is the cloud where the product is installed, e.g., aws.
Cloud Cloud `json:"cloud"`
// Owner is the owner of cloud account used to install the product, e.g., dpp.
Owner string `json:"owner"`
// Labels is the labels to select the cluster pools
Labels map[string]string `json:"labels,omitempty"`
// Timeout is how long ci-operator will wait for the cluster to be ready.
// Defaults to 1h.
Timeout *prowv1.Duration `json:"timeout,omitempty"`
}
type ClaimRelease struct {
ReleaseName string
OverrideName string
}
func (c *ClusterClaim) ClaimRelease(testName string) *ClaimRelease {
var as string
if c.As == "" {
as = LatestReleaseName
} else {
as = c.As
}
return &ClaimRelease{
ReleaseName: fmt.Sprintf("%s-%s", as, testName),
OverrideName: as,
}
}
// RegistryReferenceConfig is the struct that step references are unmarshalled into.
type RegistryReferenceConfig struct {
// Reference is the top level field of a reference config.
Reference RegistryReference `json:"ref,omitempty"`
}
// RegistryReference contains the LiteralTestStep of a reference as well as the documentation for the step.
type RegistryReference struct {
// LiteralTestStep defines the full test step that can be run by the ci-operator.
LiteralTestStep `json:",inline"`
// Documentation describes what the step being referenced does.
Documentation string `json:"documentation,omitempty"`
}
// RegistryChainConfig is the struct that chain references are unmarshalled into.
type RegistryChainConfig struct {
// Chain is the top level field of a chain config.
Chain RegistryChain `json:"chain,omitempty"`
}
// RegistryChain contains the array of steps, name, and documentation for a step chain.
type RegistryChain struct {
// As defines the name of the chain. This is how the chain will be referenced from a job's config.
As string `json:"as,omitempty"`
// Steps contains the list of steps that comprise the chain. Steps will be run in the order they are defined.
Steps []TestStep `json:"steps"`
// Documentation describes what the chain does.
Documentation string `json:"documentation,omitempty"`
// Environment lists parameters that should be set by the test.
Environment []StepParameter `json:"env,omitempty"`
// Leases lists resources that should be acquired for the test.
Leases []StepLease `json:"leases,omitempty"`
}
// RegistryWorkflowConfig is the struct that workflow references are unmarshalled into.
type RegistryWorkflowConfig struct {
// Workflow is the top level field of a workflow config.
Workflow RegistryWorkflow `json:"workflow,omitempty"`
}
// RegistryWorkflow contains the MultiStageTestConfiguration, name, and documentation for a workflow.
type RegistryWorkflow struct {
// As defines the name of the workflow. This is how the workflow will be referenced from a job's config.
As string `json:"as,omitempty"`
// Steps contains the MultiStageTestConfiguration that the workflow defines.
Steps MultiStageTestConfiguration `json:"steps,omitempty"`
// Documentation describes what the workflow does.
Documentation string `json:"documentation,omitempty"`
}
// RegistryObserverConfig is the struct that observer configs are unmarshalled into
type RegistryObserverConfig struct {
// Observer is the top level field of an observer config
Observer RegistryObserver `json:"observer,omitempty"`
}
// RegistryObserver contains the configuration and documentation for an observer
type RegistryObserver struct {
// Observer defines the observer pod
Observer `json:",inline"`
// Documentation describes what the observer being configured does.
Documentation string `json:"documentation,omitempty"`
}
// RegistryMetadata maps the registry info for each step in the registry by filename
// +k8s:deepcopy-gen=false
type RegistryMetadata map[string]RegistryInfo
// RegistryInfo contains metadata about a registry component that is useful for the web UI of the step registry
// +k8s:deepcopy-gen=false
type RegistryInfo struct {
// Path is the path of the directoryfor the registry component relative to the registry's base directory
Path string `json:"path,omitempty"`
// Owners is the OWNERS config for the registry component
Owners repoowners.Config `json:"owners,omitempty"`
}
// Observer is the configuration for an observer Pod that will run in parallel
// with a multi-stage test job.
type Observer struct {
// Name is the name of this observer
Name string `json:"name"`
// From is the container image that will be used for this observer.
From string `json:"from,omitempty"`
// FromImage is a literal ImageStreamTag reference to use for this observer.
FromImage *ImageStreamTagReference `json:"from_image,omitempty"`
// Commands is the command(s) that will be run inside the image.
Commands string `json:"commands,omitempty"`
// Resources defines the resource requirements for the step.
Resources ResourceRequirements `json:"resources,omitempty"`
// Timeout is how long the we will wait before aborting a job with SIGINT.
Timeout *prowv1.Duration `json:"timeout,omitempty"`
// GracePeriod is how long the we will wait after sending SIGINT to send
// SIGKILL when aborting this observer.
GracePeriod *prowv1.Duration `json:"grace_period,omitempty"`
// Environment has the values of parameters for the observer.
Environment []StepParameter `json:"env,omitempty"`
}
// Observers is a configuration for which observer pods should and should not
// be run during a job
type Observers struct {
// Enable is a list of named observer that should be enabled
Enable []string `json:"enable,omitempty"`
// Disable is a list of named observers that should be disabled
Disable []string `json:"disable,omitempty"`
}
// LiteralTestStep is the external representation of a test step allowing users
// to define new test steps. It gets converted to an internal LiteralTestStep
// struct that represents the full configuration that ci-operator can use.
type LiteralTestStep struct {
// As is the name of the LiteralTestStep.
As string `json:"as,omitempty"`
// From is the container image that will be used for this step.
From string `json:"from,omitempty"`
// FromImage is a literal ImageStreamTag reference to use for this step.
FromImage *ImageStreamTagReference `json:"from_image,omitempty"`
// Commands is the command(s) that will be run inside the image.
Commands string `json:"commands,omitempty"`
// Resources defines the resource requirements for the step.
Resources ResourceRequirements `json:"resources"`
// Timeout is how long the we will wait before aborting a job with SIGINT.
Timeout *prowv1.Duration `json:"timeout,omitempty"`
// GracePeriod is how long the we will wait after sending SIGINT to send
// SIGKILL when aborting a Step.
GracePeriod *prowv1.Duration `json:"grace_period,omitempty"`
// Credentials defines the credentials we'll mount into this step.
Credentials []CredentialReference `json:"credentials,omitempty"`
// Environment lists parameters that should be set by the test.
Environment []StepParameter `json:"env,omitempty"`
// Dependencies lists images which must be available before the test runs
// and the environment variables which are used to expose their pull specs.
Dependencies []StepDependency `json:"dependencies,omitempty"`
// DnsConfig for step's Pod.
DNSConfig *StepDNSConfig `json:"dnsConfig,omitempty"`
// Leases lists resources that should be acquired for the test.
Leases []StepLease `json:"leases,omitempty"`
// OptionalOnSuccess defines if this step should be skipped as long
// as all `pre` and `test` steps were successful and AllowSkipOnSuccess
// flag is set to true in MultiStageTestConfiguration. This option is
// applicable to `post` steps.
OptionalOnSuccess *bool `json:"optional_on_success,omitempty"`
// BestEffort defines if this step should cause the job to fail when the
// step fails. This only applies when AllowBestEffortPostSteps flag is set
// to true in MultiStageTestConfiguration. This option is applicable to
// `post` steps.
BestEffort *bool `json:"best_effort,omitempty"`
// NoKubeconfig determines that no $KUBECONFIG will exist in $SHARED_DIR,
// so no local copy of it will be created for the step and if the step
// creates one, it will not be propagated.
NoKubeconfig *bool `json:"no_kubeconfig,omitempty"`
// Cli is the (optional) name of the release from which the `oc` binary
// will be injected into this step.
Cli string `json:"cli,omitempty"`
// Observers are the observers that should be running