Skip to content

Commit 0f5f56f

Browse files
committed
Fix mocks function updates
Signed-off-by: melserngawy <[email protected]>
1 parent 83c4046 commit 0f5f56f

File tree

10 files changed

+644
-41
lines changed

10 files changed

+644
-41
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ spec:
8686
description: ClusterRegistryConfig represents registry config used
8787
with the cluster.
8888
properties:
89-
additionalTrustedCa:
89+
additionalTrustedCAs:
9090
additionalProperties:
9191
type: string
9292
description: |-
93-
AdditionalTrustedCa containing the registry hostname as the key, and the PEM-encoded certificate as the value,
93+
AdditionalTrustedCAs containing the registry hostname as the key, and the PEM-encoded certificate as the value,
9494
for each additional registry CA to trust.
9595
type: object
9696
allowedRegistriesForImport:
@@ -122,28 +122,30 @@ spec:
122122
properties:
123123
allowedRegistries:
124124
description: |-
125-
AllowedRegistries: registries for which image pull and push actions are allowed.
126-
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
127-
For example, *.example.com. You can specify an individual repository within a registry.
128-
For example: reg1.io/myrepo/myapp:latest. All other registries are blocked.
125+
AllowedRegistries are the registries for which image pull and push actions are allowed.
126+
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
127+
For example, *.example.com.
128+
You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
129+
All other registries are blocked.
129130
items:
130131
type: string
131132
type: array
132133
blockedRegistries:
133134
description: |-
134-
BlockedRegistries: registries for which image pull and push actions are denied.
135-
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
136-
For example, *.example.com. You can specify an individual repository within a registry.
137-
For example: reg1.io/myrepo/myapp:latest. All other registries are allowed.
135+
BlockedRegistries are the registries for which image pull and push actions are denied.
136+
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
137+
For example, *.example.com.
138+
You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
139+
All other registries are allowed.
138140
items:
139141
type: string
140142
type: array
141143
insecureRegistries:
142144
description: |-
143145
InsecureRegistries are registries which do not have a valid TLS certificate or only support HTTP connections.
144-
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
145-
For example, *.example.com. You can specify an individual repository within a registry.
146-
For example: reg1.io/myrepo/myapp:latest.
146+
To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
147+
For example, *.example.com.
148+
You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
147149
items:
148150
type: string
149151
type: array

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ type RosaControlPlaneSpec struct { //nolint: maligned
188188

189189
// RegistryConfig for ROSA-HCP cluster
190190
type RegistryConfig struct {
191-
// AdditionalTrustedCa containing the registry hostname as the key, and the PEM-encoded certificate as the value,
191+
// AdditionalTrustedCAs containing the registry hostname as the key, and the PEM-encoded certificate as the value,
192192
// for each additional registry CA to trust.
193193
// +optional
194-
AdditionalTrustedCa map[string]string `json:"additionalTrustedCa,omitempty"`
194+
AdditionalTrustedCAs map[string]string `json:"additionalTrustedCAs,omitempty"`
195195

196196
// AllowedRegistriesForImport limits the container image registries that normal users may import
197197
// images from. Set this list to the registries that you trust to contain valid Docker
@@ -221,24 +221,26 @@ type RegistryLocation struct {
221221

222222
// RegistrySources contains registries configuration.
223223
type RegistrySources struct {
224-
// AllowedRegistries: registries for which image pull and push actions are allowed.
225-
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
226-
// For example, *.example.com. You can specify an individual repository within a registry.
227-
// For example: reg1.io/myrepo/myapp:latest. All other registries are blocked.
224+
// AllowedRegistries are the registries for which image pull and push actions are allowed.
225+
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
226+
// For example, *.example.com.
227+
// You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
228+
// All other registries are blocked.
228229
// +optional
229230
AllowedRegistries []string `json:"allowedRegistries,omitempty"`
230231

231-
// BlockedRegistries: registries for which image pull and push actions are denied.
232-
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
233-
// For example, *.example.com. You can specify an individual repository within a registry.
234-
// For example: reg1.io/myrepo/myapp:latest. All other registries are allowed.
232+
// BlockedRegistries are the registries for which image pull and push actions are denied.
233+
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
234+
// For example, *.example.com.
235+
// You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
236+
// All other registries are allowed.
235237
// +optional
236238
BlockedRegistries []string `json:"blockedRegistries,omitempty"`
237239

238240
// InsecureRegistries are registries which do not have a valid TLS certificate or only support HTTP connections.
239-
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name.
240-
// For example, *.example.com. You can specify an individual repository within a registry.
241-
// For example: reg1.io/myrepo/myapp:latest.
241+
// To specify all subdomains, add the asterisk (*) wildcard character as a prefix to the domain name,
242+
// For example, *.example.com.
243+
// You can specify an individual repository within a registry, For example: reg1.io/myrepo/myapp:latest.
242244
// +optional
243245
InsecureRegistries []string `json:"insecureRegistries,omitempty"`
244246
}

controlplane/rosa/api/v1beta2/rosacontrolplane_webhook.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func (r *ROSAControlPlane) ValidateCreate() (warnings admission.Warnings, err er
4242
allErrs = append(allErrs, err)
4343
}
4444

45+
if err := r.validateClusterRegistryConfig(); err != nil {
46+
allErrs = append(allErrs, err)
47+
}
48+
4549
allErrs = append(allErrs, r.validateNetwork()...)
4650
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
4751

@@ -56,6 +60,18 @@ func (r *ROSAControlPlane) ValidateCreate() (warnings admission.Warnings, err er
5660
)
5761
}
5862

63+
func (r *ROSAControlPlane) validateClusterRegistryConfig() *field.Error {
64+
if r.Spec.ClusterRegistryConfig != nil {
65+
if r.Spec.ClusterRegistryConfig.RegistrySources != nil {
66+
if len(r.Spec.ClusterRegistryConfig.RegistrySources.AllowedRegistries) > 0 && len(r.Spec.ClusterRegistryConfig.RegistrySources.BlockedRegistries) > 0 {
67+
return field.Invalid(field.NewPath("spec.clusterRegistryConfig.registrySources"), r.Spec.ClusterRegistryConfig.RegistrySources, "allowedRegistries and blockedRegistries are mutually exclusive fields")
68+
}
69+
}
70+
}
71+
72+
return nil
73+
}
74+
5975
// ValidateUpdate implements admission.Validator.
6076
func (r *ROSAControlPlane) ValidateUpdate(old runtime.Object) (warnings admission.Warnings, err error) {
6177
var allErrs field.ErrorList

controlplane/rosa/api/v1beta2/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func (r *ROSAControlPlaneReconciler) updateOCMClusterSpec(rosaControlPlane *rosa
476476
RegistrySources: &rosacontrolplanev1.RegistrySources{},
477477
}
478478
if rosaControlPlane.Spec.ClusterRegistryConfig != nil {
479-
regConfig.AdditionalTrustedCa = rosaControlPlane.Spec.ClusterRegistryConfig.AdditionalTrustedCa
479+
regConfig.AdditionalTrustedCAs = rosaControlPlane.Spec.ClusterRegistryConfig.AdditionalTrustedCAs
480480
regConfig.AllowedRegistriesForImport = rosaControlPlane.Spec.ClusterRegistryConfig.AllowedRegistriesForImport
481481

482482
if rosaControlPlane.Spec.ClusterRegistryConfig.RegistrySources != nil {
@@ -485,8 +485,8 @@ func (r *ROSAControlPlaneReconciler) updateOCMClusterSpec(rosaControlPlane *rosa
485485
regConfig.RegistrySources.InsecureRegistries = rosaControlPlane.Spec.ClusterRegistryConfig.RegistrySources.InsecureRegistries
486486
}
487487
}
488-
if !reflect.DeepEqual(regConfig.AdditionalTrustedCa, cluster.RegistryConfig().AdditionalTrustedCa()) {
489-
ocmClusterSpec.AdditionalTrustedCa = regConfig.AdditionalTrustedCa
488+
if !reflect.DeepEqual(regConfig.AdditionalTrustedCAs, cluster.RegistryConfig().AdditionalTrustedCa()) {
489+
ocmClusterSpec.AdditionalTrustedCa = regConfig.AdditionalTrustedCAs
490490
updated = true
491491
}
492492
if !reflect.DeepEqual(regConfig.RegistrySources.AllowedRegistries, cluster.RegistryConfig().RegistrySources().AllowedRegistries()) {
@@ -502,21 +502,21 @@ func (r *ROSAControlPlaneReconciler) updateOCMClusterSpec(rosaControlPlane *rosa
502502
updated = true
503503
}
504504

505-
var newAllowedRegisters, oldAllowedRegisters []string
505+
var newAllowedRegistries, oldAllowedRegistries []string
506506
if len(regConfig.AllowedRegistriesForImport) > 0 {
507507
for id := range regConfig.AllowedRegistriesForImport {
508-
newAllowedRegisters = append(newAllowedRegisters, regConfig.AllowedRegistriesForImport[id].DomainName+":"+
508+
newAllowedRegistries = append(newAllowedRegistries, regConfig.AllowedRegistriesForImport[id].DomainName+":"+
509509
strconv.FormatBool(regConfig.AllowedRegistriesForImport[id].Insecure))
510510
}
511511
}
512512
if len(cluster.RegistryConfig().AllowedRegistriesForImport()) > 0 {
513513
for id := range cluster.RegistryConfig().AllowedRegistriesForImport() {
514-
oldAllowedRegisters = append(oldAllowedRegisters, cluster.RegistryConfig().AllowedRegistriesForImport()[id].DomainName()+":"+
514+
oldAllowedRegistries = append(oldAllowedRegistries, cluster.RegistryConfig().AllowedRegistriesForImport()[id].DomainName()+":"+
515515
strconv.FormatBool(cluster.RegistryConfig().AllowedRegistriesForImport()[id].Insecure()))
516516
}
517517
}
518-
if !reflect.DeepEqual(newAllowedRegisters, oldAllowedRegisters) {
519-
ocmClusterSpec.AllowedRegistriesForImport = strings.Join(newAllowedRegisters, ",")
518+
if !reflect.DeepEqual(newAllowedRegistries, oldAllowedRegistries) {
519+
ocmClusterSpec.AllowedRegistriesForImport = strings.Join(newAllowedRegistries, ",")
520520
updated = true
521521
}
522522

@@ -955,8 +955,8 @@ func buildOCMClusterSpec(controlPlaneSpec rosacontrolplanev1.RosaControlPlaneSpe
955955

956956
// Set the cluster registry config.
957957
if controlPlaneSpec.ClusterRegistryConfig != nil {
958-
if len(controlPlaneSpec.ClusterRegistryConfig.AdditionalTrustedCa) > 0 {
959-
ocmClusterSpec.AdditionalTrustedCa = controlPlaneSpec.ClusterRegistryConfig.AdditionalTrustedCa
958+
if len(controlPlaneSpec.ClusterRegistryConfig.AdditionalTrustedCAs) > 0 {
959+
ocmClusterSpec.AdditionalTrustedCa = controlPlaneSpec.ClusterRegistryConfig.AdditionalTrustedCAs
960960
}
961961

962962
if len(controlPlaneSpec.ClusterRegistryConfig.AllowedRegistriesForImport) > 0 {

controlplane/rosa/controllers/rosacontrolplane_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestUpdateOCMClusterSpec(t *testing.T) {
3636
Spec: rosacontrolplanev1.RosaControlPlaneSpec{
3737
AuditLogRoleARN: "arn:aws:iam::123456789012:role/AuditLogRole",
3838
ClusterRegistryConfig: &rosacontrolplanev1.RegistryConfig{
39-
AdditionalTrustedCa: map[string]string{"trusted-ca": "-----BEGIN CERTIFICATE----- testcert -----END CERTIFICATE-----"},
39+
AdditionalTrustedCAs: map[string]string{"trusted-ca": "-----BEGIN CERTIFICATE----- testcert -----END CERTIFICATE-----"},
4040
AllowedRegistriesForImport: []rosacontrolplanev1.RegistryLocation{
4141
{DomainName: "registry1.com", Insecure: false},
4242
},
@@ -91,7 +91,7 @@ func TestUpdateOCMClusterSpec(t *testing.T) {
9191
rosaControlPlane := &rosacontrolplanev1.ROSAControlPlane{
9292
Spec: rosacontrolplanev1.RosaControlPlaneSpec{
9393
ClusterRegistryConfig: &rosacontrolplanev1.RegistryConfig{
94-
AdditionalTrustedCa: map[string]string{"trusted-ca": "-----BEGIN CERTIFICATE----- testcert -----END CERTIFICATE-----"},
94+
AdditionalTrustedCAs: map[string]string{"trusted-ca": "-----BEGIN CERTIFICATE----- testcert -----END CERTIFICATE-----"},
9595
AllowedRegistriesForImport: []rosacontrolplanev1.RegistryLocation{
9696
{DomainName: "new-registry.com", Insecure: true},
9797
},
@@ -111,7 +111,7 @@ func TestUpdateOCMClusterSpec(t *testing.T) {
111111
Build()
112112

113113
expectedOCMSpec := ocm.Spec{
114-
AdditionalTrustedCa: rosaControlPlane.Spec.ClusterRegistryConfig.AdditionalTrustedCa,
114+
AdditionalTrustedCa: rosaControlPlane.Spec.ClusterRegistryConfig.AdditionalTrustedCAs,
115115
AllowedRegistriesForImport: "new-registry.com:true",
116116
AllowedRegistries: rosaControlPlane.Spec.ClusterRegistryConfig.RegistrySources.AllowedRegistries,
117117
}

pkg/cloud/services/instancestate/mock_eventbridgeiface/eventbridgeiface_mock.go

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)