-
Notifications
You must be signed in to change notification settings - Fork 426
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
Generate CRD in Go code #1097
Comments
This seems like a simple builder on top of the crd go type? |
this is just a example, I'd wish controller-gen can generated crd glue code in Go( so I can create crd when main.go started), rather than a bunch of yamls files. |
You could embed the yaml file into the binary using a Go embedded FS, and marshal that into a CRD concrete type in your main.go, without any modification of how controller-tools works today |
It could works that way(workaround by embed YAMLs ), however this issue is about the more simpler way, and another difference is if generated in Go I'd expect, it doesn't need re-generate CRD ( since no generate CRD anymore ).
maybe a option first, to keep current behavior but with extra flag to tell controller-gen the switch from YAMLs to Go code etc. |
That's a fair distinction I'm not sure how simple this would actually be, there's a difference between generating structures to marshal into YAML, and then converting that to actual Go code. This would be a fairly major feature for controller tools and I think we would want to see a good number of requests for such a large feature before committing to it Unless there's something I've missed that easily converts a structured Go type into a code that would represent the same obejct? |
CRD in Go code
I'd like to have crd write in go, and create crd when main.go runs, similar to this approach: https://github1s.com/k3s-io/helm-controller/blob/master/pkg/crd/crds.go
https://github1s.com/k3s-io/helm-controller/blob/master/main.go#L60-L61
https://pkg.go.dev/github.com/rancher/wrangler/v3/pkg/crd
https://github.com/rancher/wrangler/blob/v3.1.0/pkg/crd/print.go#L57-L64
The text was updated successfully, but these errors were encountered: