-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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 documentation for Validation Rules feature to Custom Resource Definitions task docs #30494
Conversation
|
✔️ Deploy Preview for kubernetes-io-main-staging ready! 🔨 Explore the source changes: aadf90a 🔍 Inspect the deploy log: https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/61981c1c2c9e1f0007bddbc7 😎 Browse the preview: https://deploy-preview-30494--kubernetes-io-main-staging.netlify.app |
9b129c9
to
dd93f10
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/wg api-expression |
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
spec: | ||
type: object | ||
x-kubernetes-validation-rules: | ||
- rule: "self.minReplicas <= self.replicas && self.replicas <= self.maxReplicas" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For teaching, would this work better as two separate rules in the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nifty, yes. Updated.
/assign |
692d84c
to
5f47892
Compare
921cf95
to
92f4c19
Compare
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
The `rule` under `x-kubernetes-validations` represents the expression which will be evaluated by CEL. | ||
|
||
The `message` represents the message displayed when validation fails. The message is required if the Rule contains | ||
line breaks. The message must not contain line breaks. If unset, the message is "failed rule: {Rule}". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a multi-line example showing multiple rules with messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don't think we need to be quite as detailed about the exact rules of the message field here where we first introduce it. I'd say only what it does here and then teach with an example. It's okay down at the end of the doc somewhere to spell out the exact rules if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added message into example and add the response example with message unset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of the above comment is still unaddressed right? "I don't think we need to be quite as detailed about the exact rules of the message field here where we first introduce it. I'd say only what it does here and then teach with an example. It's okay down at the end of the doc somewhere to spell out the exact rules if you want."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say only what it does here and then teach with an example.
I thought we are ok with what it has now. Reduced the details on message.
* spec: Invalid value: map[string]interface {}{"minReplicas": 0, "replicas":20, "maxReplicas": 10}: failed rule: self.minReplicas <= self.replicas && self.replicas <= self.maxReplicas | ||
``` | ||
|
||
TODO: (using text from types_jsonprops.go and KEP were applicable, but using "full" multi-line examples that include both the schema and the custom resource data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any multi-line examples that have both the schema and the custom resource data being validated? I think that really helps explain the idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions.md
Outdated
Show resolved
Hide resolved
type: object | ||
x-kubernetes-validation-rules: | ||
- rule: "self.minReplicas <= self.replicas" | ||
message: "replicas should be greater than minReplicas." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "should be greater than or equal to" or "should not be less than"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
5295628
to
aadf90a
Compare
@jpbetz Can you rebase this PR to the |
/close All commits have been moved to #30626 which is against |
@cici37: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Authors: @cici37, @jpbetz
Document the Validation Rules feature (alpha in 1.23)