code-generator icon indicating copy to clipboard operation
code-generator copied to clipboard

Generate json-schema from go types

Open erictune opened this issue 7 years ago • 15 comments

When you create a CRD, it can have a schema defined using json-schema.

In github.com/kubernetes/sample-controller the client libraries for a controller are generated from a go API definition, and CRDs are created, but there is no schema for the CRD, which means less validation.

It would be nice to generate the json-schema for the CRD from the Go types. So, this is proposing a new generator that generates json-schema for CRDs from go types.

erictune avatar Dec 12 '17 03:12 erictune

xref https://github.com/kubernetes/sample-controller/issues/2

erictune avatar Dec 12 '17 03:12 erictune

/cc @sttts @munnerz @mbohlool

nikhita avatar Dec 12 '17 04:12 nikhita

@erictune we discussed the very same idea at KubeCon. We have openapi-gen which produces a Golang snippet now which is very similar to a JSON Schema already. @munnerz wanted to prototype a change to openapi-gen with your described goal.

sttts avatar Dec 12 '17 06:12 sttts

Yep - likely I won't have a chance to get onto this until next week, as this is my final week before xmas. I think @sttts and I discussed initially adding an 'output format' parameter to openapi-gen in order to facilitate this.

munnerz avatar Dec 12 '17 10:12 munnerz

/assign

mbohlool avatar Dec 12 '17 19:12 mbohlool

+1 to this. I'm looking into having the cluster registry be a CRD and this would be a boon for that.

perotinus avatar Mar 07 '18 20:03 perotinus

https://github.com/kubernetes/kube-openapi/pull/37 needs review time.

sttts avatar Mar 08 '18 07:03 sttts

I’m happy to follow up with additional features (such as comments tags to allow specifying regex’s to validate with, etc) once the structure/design is accepted too.

I just didn’t want to rush ahead and introduce a load of new functionality without being sure that the way it’s implemented makes sense! On Thu, 8 Mar 2018 at 07:31, Dr. Stefan Schimanski [email protected] wrote:

kubernetes/kube-openapi#37 https://github.com/kubernetes/kube-openapi/pull/37 needs review time.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/kubernetes/code-generator/issues/28#issuecomment-371404172, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMbP-0p3ZXuuHRFBGV3uXD42qCST1Efks5tcN5jgaJpZM4Q-YKH .

munnerz avatar Mar 08 '18 07:03 munnerz

I just came across this which looks similar: https://github.com/ant31/crd-validation

erictune avatar Mar 19 '18 17:03 erictune

I expect we will take this on in kube-openapi and not here.

lavalamp avatar Jun 11 '18 17:06 lavalamp

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Sep 09 '18 17:09 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Oct 09 '18 18:10 fejta-bot

/lifecycle frozen

On Tue, Oct 9, 2018 at 11:52 PM fejta-bot [email protected] wrote:

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta https://github.com/fejta. /lifecycle rotten

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kubernetes/code-generator/issues/28#issuecomment-428297792, or mute the thread https://github.com/notifications/unsubscribe-auth/APXA0B2EtSWfjmfM0G2tSme-gH3-22mFks5ujOlNgaJpZM4Q-YKH .

nikhita avatar Oct 09 '18 18:10 nikhita

/unassign mbohlool

mbohlool avatar Apr 15 '19 05:04 mbohlool

Work on this is going on in http://github.com/kubernetes-sigs/controller-tools.

sttts avatar Apr 15 '19 09:04 sttts

/close

stale?

thockin avatar Mar 12 '24 20:03 thockin

@thockin: Closing this issue.

In response to this:

/close

stale?

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.

k8s-ci-robot avatar Mar 12 '24 20:03 k8s-ci-robot