-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Create CRD validation specs in CRD manifests and as Go code #869
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
Conversation
646711a to
6e3f3e1
Compare
…CRD manifests commands/.../add/api.go: call OpenAPI generator function pkg/scaffold/crd*: use CustomRenderer interface to write CRD manifests with validation spec instead of a template pkg/scaffold/gopkgtoml*: include openapi-gen deps pkg/scaffold/types*: add openapi-gen directives
remove status field from resulting struct
6e3f3e1 to
cdb791c
Compare
…generator condition
|
Any update on this PR? Seems pretty solid, have been testing it with some basic types to CRD generation, and so far so good |
hasbro17
left a comment
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 after nits.
@estroz As we discussed offline I'm fine with having users using the +kubebuilder:validation tags to add the custom validation directives.
But as a follow up to this PR we should try to look into not stomping out any validation directives that are added directly to the CRD yaml manifest on running generate openapi.
|
Also the CHANGELOG and cli-reference guide need to be updated but it's fine if you have that lined up in follow up PR to add the docs. |
…s if explicitly adding them
0f5a186 to
613ac72
Compare
|
The additions in this PR to the generated |
3fff291 to
b46c19a
Compare
84de2a9 to
4c50988
Compare
Description of the change:
operator-sdk generate openapigenerates OpenAPI validation specs for CRD manifests and as Go code underpkg/apis/<group>/<version>/zz_generated.openapi.go.operator-sdk add apialso calls the openapi generator. The CRD scaffold now implementsCustomRendererto generate a CRD using controller-tools' CRD generator by default; if some CRD manifest exists,CustomRenderwill only set the validation spec of that CRD.Motivation for the change: validation specs should be present for all CRD's, yaml or otherwise. Users might want to use the Go specs for Go-defined CRD's.
Note: we can remove Go spec generator, as there haven't been requests for one. I thought it would be a nice addition but not necessary. I'm also open to not having a separate generate command, and having all generation under
generate k8s.I'll add documentation in another PR since this one is already large.
Closes #256