Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CEL validation to our CRDs #11068

Merged

Conversation

scholzj
Copy link
Member

@scholzj scholzj commented Jan 22, 2025

Type of change

  • Enhancement / new feature

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 using jmxPrometheusExporter 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 and reason do not seem to be supported until Kube 1.28. So it should not be used yet in Strimzi

This PR should close #9417.

Checklist

  • Write tests
  • Make sure all tests pass
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@katheris katheris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and this looks like a great feature to be able to use in future

@scholzj scholzj merged commit 283e1b0 into strimzi:main Jan 23, 2025
13 checks passed
@scholzj scholzj deleted the add-support-for-CEL-validation-in-our-CRDs branch January 23, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use CEL validation in our CRDs
3 participants