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

feat: Add XValidations in the generated documentation #214

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

trynity
Copy link
Contributor

@trynity trynity commented Mar 1, 2023

With Kubernetes 1.25, CEL will be added, as an alternative to enforcing validations, rather than webhooks. This allows, among other things, the ability to enforce immutability on fields.

Since this is documented in the CRD YAML itself, bubbling this up into the documentation allows one to see custom validation rules

An example kubebuilder comment in Go would be:

// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable"

This would result in the following in the CRD:

x-kubernetes-validations:
- message: Value is immutable
  rule: self == oldSelf

And now the generated documentation will reflect this:

<i>Validations</i>:<li>self == oldSelf: Value is immutable</li>

@trynity trynity force-pushed the trynity-add-xvalidations branch 2 times, most recently from 1d196b0 to a9773b8 Compare March 6, 2023 14:25
@trynity
Copy link
Contributor Author

trynity commented Mar 6, 2023

@fybrik Please let me know if this is acceptable

With Kubernetes 1.25, CEL will be added, as an alternative to enforcing
validations, rather than webhooks. This allows, among other things,
the ability to enforce immutability on fields.

Since this is documented in the CRD YAML itself, bubbling this up
into the documentation allows one to see custom validation rules

An example kubebuilder comment in Go would be:

```
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable"
```

This would result in the following in the CRD:

```
x-kubernetes-validations:
- message: Value is immutable
  rule: self == oldSelf
```

And now the generated documentation will reflect this:

```
<i>Validations</i>:<li>self == oldSelf: Value is immutable</li>
```

Signed-off-by: Trynity Mirell <trynity@mirell.org>
Copy link
Contributor

@roytman roytman left a comment

Choose a reason for hiding this comment

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

Hi @trynity, thanks for the PR

@roytman roytman merged commit be3391c into fybrik:main Mar 14, 2023
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.

2 participants