Skip to content

Commit 4db0990

Browse files
committed
add CEL validation for RegistrySources in Image API
1 parent 01b3675 commit 4db0990

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

config/v1/types_image.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ type RegistryLocation struct {
162162
}
163163

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ spec:
139139
type: array
140140
x-kubernetes-list-type: atomic
141141
type: object
142+
x-kubernetes-validations:
143+
- message: Only one of BlockedRegistries or AllowedRegistries may
144+
be set
145+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
146+
== 0 : true'
142147
type: object
143148
status:
144149
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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ spec:
139139
type: array
140140
x-kubernetes-list-type: atomic
141141
type: object
142+
x-kubernetes-validations:
143+
- message: Only one of BlockedRegistries or AllowedRegistries may
144+
be set
145+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
146+
== 0 : true'
142147
type: object
143148
status:
144149
description: status holds observed values from the cluster. They may not

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ spec:
139139
type: array
140140
x-kubernetes-list-type: atomic
141141
type: object
142+
x-kubernetes-validations:
143+
- message: Only one of BlockedRegistries or AllowedRegistries may
144+
be set
145+
rule: 'self.blockedRegistries.size() > 0 ? self.allowedRegistries.size()
146+
== 0 : true'
142147
type: object
143148
status:
144149
description: status holds observed values from the cluster. They may not

0 commit comments

Comments
 (0)