Skip to content
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

Generated names are extremely long, as opposed to some organization that would be easier to use #1543

Open
wmcnamee-coreweave opened this issue Aug 7, 2024 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.

Comments

@wmcnamee-coreweave
Copy link

Bug Report

Shorter schema names from generated code.

1. Minimal reproduce step (Required)

[email protected]:argoproj/argo-workflows.git
kcl import -m crd -o lib -s ./argo-workflows/manifests/base/crds/full/argoproj.io_clusterworkflowtemplates.yaml

2. What did you expect to see? (Required)

shorter schema names, organized

3. What did you see instead (Required)

schema ArgoprojIoV1alpha1ClusterWorkflowTemplateSpecAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0PreferenceMatchFieldsItems0

4. What is your KCL components version? (Required)

kcl --version
kcl version 0.9.6
@Peefy Peefy added tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc. enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Aug 13, 2024
@wmcnamee-coreweave
Copy link
Author

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.

@Peefy
Copy link
Contributor

Peefy commented Aug 14, 2024

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

@wmcnamee-coreweave
Copy link
Author

wmcnamee-coreweave commented Aug 14, 2024

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.

@Peefy
Copy link
Contributor

Peefy commented Aug 15, 2024

Thank you! @wmcnamee-coreweave PRs welcome!

For Go struct to KCL module, track issue is here. kcl-lang/kcl-go#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.
Projects
None yet
Development

No branches or pull requests

2 participants