Skip to content

cmd/cue: get go should support optional field comments #2679

@uhthomas

Description

@uhthomas

Is your feature request related to a problem? Please describe.

The Kuberentes ecosystem use comments to denote whether a field is optional or required. The comment has a direct effect on the produced OpenAPI schema, and often means otherwise correct Go "schemas" will be represented incorrectly with CUE.

https://github.com/kubernetes/community/blob/e977e6ea355f26130ca555d1e8704893727ee024/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required

Describe the solution you'd like

CUE should consider the +optional comment when evaluating whether a field is optional.

https://github.com/cue-lang/cue/blob/273602f2266fd12b2aa6f42a6f3119c1294b7fb9/cmd/cue/cmd/get_go.go#L1397C21-L1397C31

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions