Skip to content

Commit ed8749d

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

File tree

10 files changed

+609
-14
lines changed

10 files changed

+609
-14
lines changed

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

Lines changed: 2 additions & 2 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:

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 2 additions & 2 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

controlplane/rosa/api/v1beta2/rosacontrolplane_webhook.go

Lines changed: 12 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,14 @@ func (r *ROSAControlPlane) ValidateCreate() (warnings admission.Warnings, err er
5660
)
5761
}
5862

63+
func (r *ROSAControlPlane) validateClusterRegistryConfig() *field.Error {
64+
if len(r.Spec.ClusterRegistryConfig.RegistrySources.AllowedRegistries) > 0 && len(r.Spec.ClusterRegistryConfig.RegistrySources.BlockedRegistries) > 0 {
65+
return field.Invalid(field.NewPath("spec.clusterRegistryConfig.registrySources"), r.Spec.ClusterRegistryConfig.RegistrySources, "allowedRegistries and blockedRegistries are mutually exclusive fields")
66+
}
67+
68+
return nil
69+
}
70+
5971
// ValidateUpdate implements admission.Validator.
6072
func (r *ROSAControlPlane) ValidateUpdate(old runtime.Object) (warnings admission.Warnings, err error) {
6173
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: 5 additions & 5 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()) {
@@ -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.

pkg/cloud/services/ssm/mock_ssmiface/ssmapi_mock.go

Lines changed: 83 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)