Skip to content

Commit ad2927a

Browse files
committed
add CEL validation for RegistrySources in Image API
1 parent 3efee42 commit ad2927a

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

config/v1/types_image.go

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ type RegistryLocation struct {
112112
}
113113

114114
// RegistrySources holds cluster-wide information about how to handle the registries config.
115+
//
116+
// +kubebuilder:validation:XValidation:rule="self.blockedRegistries.size() > 0 ? self.allowedRegistries.size() == 0 : true",message="Only one of BlockedRegistries or AllowedRegistries may be set"
115117
type RegistrySources struct {
116118
// insecureRegistries are registries which do not have a valid TLS certificates or only support HTTP connections.
117119
// +optional

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_images.crd.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ spec:
132132
type: string
133133
type: array
134134
type: object
135+
x-kubernetes-validations:
136+
- message: Only one of BlockedRegistries or AllowedRegistries may
137+
be set
138+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
139+
== 0 : true'
135140
type: object
136141
status:
137142
description: status holds observed values from the cluster. They may not

config/v1/zz_generated.featuregated-crd-manifests/images.config.openshift.io/AAA_ungated.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ spec:
133133
type: string
134134
type: array
135135
type: object
136+
x-kubernetes-validations:
137+
- message: Only one of BlockedRegistries or AllowedRegistries may
138+
be set
139+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
140+
== 0 : true'
136141
type: object
137142
status:
138143
description: status holds observed values from the cluster. They may not

payload-manifests/crds/0000_10_config-operator_01_images.crd.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ spec:
132132
type: string
133133
type: array
134134
type: object
135+
x-kubernetes-validations:
136+
- message: Only one of BlockedRegistries or AllowedRegistries may
137+
be set
138+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
139+
== 0 : true'
135140
type: object
136141
status:
137142
description: status holds observed values from the cluster. They may not

0 commit comments

Comments
 (0)