Skip to content

Commit 07641e8

Browse files
authored
Merge branch 'openshift:main' into DPTP-4341
2 parents 3b1beed + 675bfdb commit 07641e8

File tree

9 files changed

+153
-40
lines changed

9 files changed

+153
-40
lines changed

pkg/api/promotion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const (
2020

2121
PromotionStepName = "promotion"
2222
PromotionQuayStepName = "promotion-quay"
23+
24+
PromotionExcludeImageWildcard = "*"
2325
)
2426

2527
// PromotionTargets adapts the single-target configuration to the multi-target paradigm.

pkg/api/types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,11 @@ type StepParameter struct {
11131113
type CredentialReference struct {
11141114
// Namespace is where the source secret exists.
11151115
Namespace string `json:"namespace"`
1116-
// Names is which source secret to mount.
1116+
// Collection is the name of the collection the secret belongs to.
1117+
// In GCP, the secret is named <collection>__<secret-name> -- this represents
1118+
// the <collection> part.
1119+
Collection string `json:"collection"`
1120+
// Name is the name of the secret, without the collection prefix.
11171121
Name string `json:"name"`
11181122
// MountPath is where the secret should be mounted.
11191123
MountPath string `json:"mount_path"`
@@ -1321,6 +1325,7 @@ const (
13211325
ClusterProfileAWS1QE ClusterProfile = "aws-1-qe"
13221326
ClusterProfileAWSAutoreleaseQE ClusterProfile = "aws-autorelease-qe"
13231327
ClusterProfileAWSSdQE ClusterProfile = "aws-sd-qe"
1328+
ClusterProfileOEXAWSQE ClusterProfile = "oex-aws-qe"
13241329
ClusterProfileAWSPerfScale ClusterProfile = "aws-perfscale"
13251330
ClusterProfileAWSPerfScaleQE ClusterProfile = "aws-perfscale-qe"
13261331
ClusterProfileAWSPerfScaleLRCQE ClusterProfile = "aws-perfscale-lrc-qe"
@@ -1495,6 +1500,7 @@ func ClusterProfiles() []ClusterProfile {
14951500
ClusterProfileAWS1QE,
14961501
ClusterProfileAWSAutoreleaseQE,
14971502
ClusterProfileAWSSdQE,
1503+
ClusterProfileOEXAWSQE,
14981504
ClusterProfileAWSSC2SQE,
14991505
ClusterProfileAWSSCPQE,
15001506
ClusterProfileAWSOutpostQE,
@@ -1662,6 +1668,7 @@ func (p ClusterProfile) ClusterType() string {
16621668
ClusterProfileAWS1QE,
16631669
ClusterProfileAWSAutoreleaseQE,
16641670
ClusterProfileAWSSdQE,
1671+
ClusterProfileOEXAWSQE,
16651672
ClusterProfileAWSVirtualization,
16661673
ClusterProfileFleetManagerQE,
16671674
ClusterProfileAWSPerfScale,
@@ -1911,6 +1918,8 @@ func (p ClusterProfile) LeaseType() string {
19111918
return "aws-autorelease-qe-quota-slice"
19121919
case ClusterProfileAWSSdQE:
19131920
return "aws-sd-qe-quota-slice"
1921+
case ClusterProfileOEXAWSQE:
1922+
return "oex-aws-qe-quota-slice"
19141923
case ClusterProfileAWSOutpostQE:
19151924
return "aws-outpost-qe-quota-slice"
19161925
case ClusterProfileAWSC2SQE:

pkg/promotion/promotion.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"k8s.io/apimachinery/pkg/util/sets"
99
"sigs.k8s.io/prow/pkg/flagutil"
1010

11+
"github.com/openshift/ci-tools/pkg/api"
1112
cioperatorapi "github.com/openshift/ci-tools/pkg/api"
1213
"github.com/openshift/ci-tools/pkg/config"
1314
)
@@ -39,13 +40,13 @@ func AllPromotionImageStreamTags(configSpec *cioperatorapi.ReleaseBuildConfigura
3940
continue
4041
}
4142

42-
disabled := sets.New[string](target.ExcludedImages...)
43-
if !disabled.Has("*") {
43+
disabled := sets.New(target.ExcludedImages...)
44+
if !disabled.Has(api.PromotionExcludeImageWildcard) {
4445
for _, image := range configSpec.Images {
4546
result.Insert(fmt.Sprintf("%s/%s:%s", target.Namespace, target.Name, image.To))
4647
}
4748
}
48-
for _, image := range disabled.Delete("*").UnsortedList() {
49+
for _, image := range disabled.Delete(api.PromotionExcludeImageWildcard).UnsortedList() {
4950
delete(result, image)
5051
}
5152

pkg/steps/multi_stage/init.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (s *multiStageTestStep) createSPCs(ctx context.Context) error {
9696
if _, exists := toCreate[name]; exists {
9797
continue
9898
}
99-
secret, err := getSecretString(credential.Name)
99+
secret, err := getSecretString(credential.Collection, credential.Name)
100100
if err != nil {
101101
return err
102102
}
@@ -128,10 +128,10 @@ func (s *multiStageTestStep) createSPCs(ctx context.Context) error {
128128
return nil
129129
}
130130

131-
func getSecretString(name string) (string, error) {
131+
func getSecretString(collection, name string) (string, error) {
132132
secret := config.Secret{
133-
ResourceName: fmt.Sprintf("projects/%s/secrets/%s/versions/latest", GSMproject, name),
134-
Path: name,
133+
ResourceName: fmt.Sprintf("projects/%s/secrets/%s__%s/versions/latest", GSMproject, collection, name),
134+
FileName: name, // we want to mount the secret as a file named without the collection prefix
135135
}
136136
y, err := yaml.Marshal([]config.Secret{secret})
137137
if err != nil {

pkg/steps/multi_stage/init_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func TestCreateSPCs(t *testing.T) {
5757
scheme := runtime.NewScheme()
5858
_ = csiapi.AddToScheme(scheme)
5959

60-
credential1 := api.CredentialReference{Name: "credential1"}
61-
credential2 := api.CredentialReference{Name: "credential2"}
60+
credential1 := api.CredentialReference{Name: "credential1", Collection: "test"}
61+
credential2 := api.CredentialReference{Name: "credential2", Collection: "test-2"}
6262

63-
newSPC := func(name, ns string) csiapi.SecretProviderClass {
64-
secret, _ := getSecretString(name)
63+
newSPC := func(collection, name, ns string) csiapi.SecretProviderClass {
64+
secret, _ := getSecretString(collection, name)
6565

6666
return csiapi.SecretProviderClass{
6767
TypeMeta: meta.TypeMeta{
@@ -98,7 +98,7 @@ func TestCreateSPCs(t *testing.T) {
9898
pre: []api.LiteralTestStep{{Credentials: []api.CredentialReference{credential1}}},
9999
expectedSPCs: csiapi.SecretProviderClassList{
100100
Items: []csiapi.SecretProviderClass{
101-
newSPC(credential1.Name, "test-ns"),
101+
newSPC(credential1.Collection, credential1.Name, "test-ns"),
102102
},
103103
},
104104
},
@@ -108,8 +108,8 @@ func TestCreateSPCs(t *testing.T) {
108108
test: []api.LiteralTestStep{{Credentials: []api.CredentialReference{credential2}}},
109109
expectedSPCs: csiapi.SecretProviderClassList{
110110
Items: []csiapi.SecretProviderClass{
111-
newSPC(credential1.Name, "test-ns"),
112-
newSPC(credential2.Name, "test-ns"),
111+
newSPC(credential1.Collection, credential1.Name, "test-ns"),
112+
newSPC(credential2.Collection, credential2.Name, "test-ns"),
113113
},
114114
},
115115
},
@@ -120,8 +120,8 @@ func TestCreateSPCs(t *testing.T) {
120120
post: []api.LiteralTestStep{{Credentials: []api.CredentialReference{credential1}}},
121121
expectedSPCs: csiapi.SecretProviderClassList{
122122
Items: []csiapi.SecretProviderClass{
123-
newSPC(credential1.Name, "test-ns"),
124-
newSPC(credential2.Name, "test-ns"),
123+
newSPC(credential1.Collection, credential1.Name, "test-ns"),
124+
newSPC(credential2.Collection, credential2.Name, "test-ns"),
125125
},
126126
},
127127
},
@@ -131,8 +131,8 @@ func TestCreateSPCs(t *testing.T) {
131131
test: []api.LiteralTestStep{{Credentials: []api.CredentialReference{credential2}}},
132132
expectedSPCs: csiapi.SecretProviderClassList{
133133
Items: []csiapi.SecretProviderClass{
134-
newSPC(credential1.Name, "test-ns"),
135-
newSPC(credential2.Name, "test-ns"),
134+
newSPC(credential1.Collection, credential1.Name, "test-ns"),
135+
newSPC(credential2.Collection, credential2.Name, "test-ns"),
136136
},
137137
},
138138
},
@@ -174,8 +174,9 @@ func TestCreateSPCs(t *testing.T) {
174174

175175
func TestGetSecretString(t *testing.T) {
176176
name := "secret-name"
177+
collection := "collection1"
177178

178-
yamlString, err := getSecretString(name)
179+
yamlString, err := getSecretString(collection, name)
179180
if err != nil {
180181
t.Fatalf("unexpected error getting secret string: %v", err)
181182
}
@@ -195,8 +196,8 @@ func TestGetSecretString(t *testing.T) {
195196
}
196197

197198
expectedSecret := config.Secret{
198-
ResourceName: fmt.Sprintf("projects/%s/secrets/%s/versions/latest", GSMproject, name),
199-
Path: name,
199+
ResourceName: fmt.Sprintf("projects/%s/secrets/%s__%s/versions/latest", GSMproject, collection, name),
200+
FileName: name,
200201
}
201202

202203
// Compare the actual and expected secret

pkg/steps/release/promote.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,17 @@ func toPromote(config api.PromotionTarget, images []api.ProjectDirectoryImageBui
323323
names.Insert(tag)
324324
}
325325
}
326+
326327
for _, tag := range config.ExcludedImages {
328+
if tag == api.PromotionExcludeImageWildcard {
329+
clear(tagsByDst)
330+
names.Clear()
331+
break
332+
}
327333
delete(tagsByDst, tag)
328334
names.Delete(tag)
329335
}
336+
330337
for dst, src := range config.AdditionalImages {
331338
tagsByDst[dst] = src
332339
names.Insert(dst)

pkg/steps/release/promote_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,68 @@ func TestPromotedTagsWithRequiredImages(t *testing.T) {
594594
},
595595
expectedRequiredImages: sets.New[string]("base", "base-7", "base-8", "other"),
596596
},
597+
{
598+
name: "promotion only cli-ocm to ci",
599+
input: &api.ReleaseBuildConfiguration{
600+
Images: []api.ProjectDirectoryImageBuildStepConfiguration{
601+
{
602+
From: "cli",
603+
To: "cli-ocm",
604+
},
605+
{
606+
From: "src",
607+
To: "cli",
608+
},
609+
},
610+
PromotionConfiguration: &api.PromotionConfiguration{
611+
Targets: []api.PromotionTarget{
612+
{
613+
ExcludedImages: []string{api.PromotionExcludeImageWildcard},
614+
Namespace: "ci",
615+
Name: "cli-ocm",
616+
AdditionalImages: map[string]string{
617+
"latest": "cli-ocm",
618+
},
619+
},
620+
{
621+
Namespace: "ocp",
622+
Name: "4.20",
623+
},
624+
},
625+
},
626+
Metadata: api.Metadata{
627+
Org: "openshift",
628+
Repo: "oc",
629+
Branch: "master",
630+
},
631+
},
632+
expected: map[string][]api.ImageStreamTagReference{
633+
"cli-ocm": {
634+
{Namespace: "ci", Name: "cli-ocm", Tag: "latest"},
635+
{Namespace: "ocp", Name: "4.20", Tag: "cli-ocm"},
636+
},
637+
"cli": {
638+
{Namespace: "ocp", Name: "4.20", Tag: "cli"},
639+
},
640+
},
641+
expectedRequiredImages: sets.New("latest", "cli-ocm", "cli"),
642+
},
643+
{
644+
name: "exclude everything",
645+
input: &api.ReleaseBuildConfiguration{
646+
Images: []api.ProjectDirectoryImageBuildStepConfiguration{
647+
{To: "img_a"},
648+
{To: "img_b"},
649+
},
650+
PromotionConfiguration: &api.PromotionConfiguration{
651+
Targets: []api.PromotionTarget{{
652+
ExcludedImages: []string{api.PromotionExcludeImageWildcard},
653+
}},
654+
},
655+
},
656+
expected: map[string][]api.ImageStreamTagReference{},
657+
expectedRequiredImages: sets.New[string](),
658+
},
597659
}
598660

599661
for _, testCase := range testCases {

pkg/util/testgrid.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func IsSpecialInformingJobOnTestGrid(jobName string) bool {
1717
"periodic-ci-shiftstack-ci-release-",
1818
"promote-release-openshift-",
1919
"release-openshift-",
20+
"periodic-ci-openshift-operator-framework-operator-controller-",
2021
}
2122
for _, prefix := range testGridInformingPrefixes {
2223
if strings.HasPrefix(jobName, prefix) {

0 commit comments

Comments
 (0)