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

Support messageExpression in CRD validation rules #858

Closed
pmalek opened this issue Nov 8, 2023 · 7 comments · Fixed by #927
Closed

Support messageExpression in CRD validation rules #858

pmalek opened this issue Nov 8, 2023 · 7 comments · Fixed by #927
Assignees

Comments

@pmalek
Copy link
Contributor

pmalek commented Nov 8, 2023

Problem statement

Currently, kubebuilder supports rule and message fields when specifying +kubebuilder:validation:XValidation.

Kubernetes 1.25 introduced CRD validation rules (beta0 which also allow specifying messageExpression.

The following is now possible when specifying CRD validations:

x-kubernetes-validations:
- rule: "self.x <= self.maxLimit"
  messageExpression: '"x exceeded max limit of " + string(self.maxLimit)'

Unfortunately kubebuilder doesn't support this:

unknown argument "messageExpression" (at <input>:1:117)

This issue tracks the proposal and implementation of support for messageExpression in // +kubebuilder:validation:XValidation.

https://book.kubebuilder.io/reference/markers/crd-validation.html

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 6, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 7, 2024
@JoelSpeed
Copy link
Contributor

/remove-lifecycle rotten

We should definitely be implementing this support

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Mar 7, 2024
@pmalek
Copy link
Contributor Author

pmalek commented Mar 7, 2024

I'd be willing to contribute a patch for this if someone provided guidance what would be needed.

@sbueringer
Copy link
Member

@pmalek I think you can start from here:

type XValidation struct {

and then try to implement it analog to Rule and/or Message

(also grep for rule/message in the repo in general and see if there are relevant occurences)

Apologies for the fuzzy guidance but that's literally all I know without diving a lot deeper into it :)

@pmalek
Copy link
Contributor Author

pmalek commented Apr 21, 2024

Thanks @sbueringer 🙇

I've pushed #927 with an attempt to provide support for messageExpression. Thanks for guidance.

@pmalek
Copy link
Contributor Author

pmalek commented Apr 21, 2024

/assign

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 a pull request may close this issue.

5 participants