-
Notifications
You must be signed in to change notification settings - Fork 1.8k
doc: add OpenAPI validation info to user guide #1640
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
doc: add OpenAPI validation info to user guide #1640
Conversation
The generated YAML CRD created when running `operator-sdk add api ...` includes an OpenAPI v3.0 validation section. E.g. ```YAML validation: openAPIV3Schema: properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' type: string kind: description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' type: string metadata: type: object spec: type: object status: type: object ``` The properties for a CRD should be specified here for validation. In the case of the Memcached example, a `size` property should be added to the generated CRD. This change documents that process in the user guide.
doc/user-guide.md
Outdated
$ operator-sdk generate k8s | ||
``` | ||
|
||
Update the Open API validation section in the CRD at `deploy/crds/cache_v1alpha1_memcached_crd.yaml` so that Kubernetes can validate the properties in a Memcached Custom Resource when it is created or updated. |
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 should read something like:
To update the OpenAPI validation section in the CRD `deploy/crds/cache_v1alpha1_memcached_crd.yaml`, run the following command:
\```console
$ operator-sdk generate openapi
\```
This validation section allows Kubernetes to validate the properties in a Memcached Custom Resource when it is created or updated. An example of the generated YAML is as follows:
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.
Oh! I didn't realize that generate openapi
was available. Thanks for this. The change has been made.
/test e2e-aws-ansible |
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.
Thanks for this, once the suggestion that @estroz left is addressed this can be merged.
/lgtm
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.
/lgtm
@estroz We don't have any of the upstream validation directive tags documented anywhere yet right? |
Co-Authored-By: Haseeb Tariq <hasbro17@gmail.com>
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.
/lgtm
Thanks for this! |
Description of the change:
The generated YAML CRD created when running
operator-sdk add api ...
includes an OpenAPI v3.0 validation section. E.g.
The properties for a CRD should be specified here for validation.
In the case of the Memcached example, a
size
property should beadded to the generated CRD. This change documents that process in
the user guide.
Motivation for the change:
I got hung up on this when going through the tutorial. I thought I was missing a step or something wasn't right when examining the generated CRD files and following the user guide. Perhaps this will make it a little clearer for people just starting out.