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

Cleanup generator code #18

Open
varshaprasad96 opened this issue May 23, 2022 · 0 comments
Open

Cleanup generator code #18

varshaprasad96 opened this issue May 23, 2022 · 0 comments

Comments

@varshaprasad96
Copy link
Contributor

Passing data to templates using structs is not scalable. For every customization that needs a new field, we need to add a new exported field to either API, Package or InterfaceWrapper struct.
Reference: https://github.com/kcp-dev/code-generator/blob/main/pkg/internal/parser.go#L51-L73
Initializing a new struct and passing info for templates:

a, err := internal.NewAPI(root, info, string(version.Version), gv.PackageName, !isClusterScoped(info), hasStatusSubresource(info), &outContent)

Instead of this convoluted process, inspired from upstream code-gen use a map[string]inteface{} and keep adding new keys for any additional fields.
Reference: https://github.com/kubernetes/code-generator/blob/7d977b3e5454e47ec6b903242616e9ea62644226/cmd/client-gen/generators/generator_for_type.go#L147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant