Skip to content

Cleanup generator code #18

Open
Open
@varshaprasad96

Description

@varshaprasad96

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions