Open wmcnamee-coreweave opened 2 months ago
if there was a KCL generator for Go types, instead of OpenAPI or CRDs, then the same organization in the Go code could be ported over. Leaving shorter names.
Yes, we can organize names by package names instead of long schema names. In fact, KCL import OpenAPI has been organized by package name, just like the k8s package https://github.com/kcl-lang/modules/tree/main/k8s/1.31, through the swagger file https://github.com/kcl-lang/modules/blob/main/scripts/k8s/processed-swagger.json
I looked at the argo-workflow
module (which I think is also misnamed, should be argo-workflows
), and I went through a time-boxed 30m exercise to clean it up. I found that a lot of the fields used are actually types coming straight from k8s
but are instead inlined in that module. In that 30m, I was able to reduce this file (https://github.com/kcl-lang/modules/blob/main/argo-workflow/v1alpha1/argoproj_io_v1alpha1_workflow.k) from 3.37MB to 2.7MB just by fixing references to schemas upstream, but there was a lot more that I could do. I used this as my primary source of information: https://github.com/argoproj/argo-workflows/blob/main/pkg/apis/workflow/v1alpha1/workflow_types.go
This leads me to believe that a potentially better way to generate schemas is by looking at/parsing Go. Anyways, just some shower thoughts.
Thank you! @wmcnamee-coreweave PRs welcome!
For Go struct to KCL module, track issue is here. https://github.com/kcl-lang/kcl-go/issues/332
Actually, this work is underway and I have successfully converted some of the argoworkflows go code. There are still some errors that need to be fixed.
Bug Report
Shorter schema names from generated code.
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
shorter schema names, organized
3. What did you see instead (Required)
4. What is your KCL components version? (Required)