Add support for CEL validation to our CRDs #11068
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Description
This PR adds support for using CEL validations in our CRDs. It uses an annotation to add the CEL validation rules on a type or on a getter.
The CEL validation rules can be used to improve the validation of our CRDs beyond what the OpanAPI allows. Right now, this PR does not add the rules to any actual API classes. But it is expected to be used for example here: #11051 (review) to make the
valueFrom
field required when usingjmxPrometheusExporter
metrics.In general, the CEL validation rules should not be used for any existing fields to make the validation more strict than it was before, as that might cause backward compatibility issues. It should be used only for new APIs or when we remove some previous restrictions (such as in #11051 where the
valueFrom
field is made conditionally optional instead of required).The Pr adds support for all the options of the CEL validation rules. However,
fieldPath
andreason
do not seem to be supported until Kube 1.28. So it should not be used yet in StrimziThis PR should close #9417.
Checklist