Skip to content

Align kube-openapi validation with controller-gen for +listType marker #554

@lalitc375

Description

@lalitc375

Summary:

The kube-openapi tool currently allows the // +listType marker to be used on fields that are not lists or slices. This can lead to the generation of an invalid OpenAPI schema, which in turn causes issues for tools that consume this schema, such as controller-gen.

Problem:

A +listType=atomic marker was incorrectly applied to the metav1.Status.Details field, which is a struct, not a list type. This incorrect marker was introduced in commit bfbbdecc.

This issue causes controller-gen to fail when generating Custom Resource Definitions (CRDs) that embed metav1.Status, as controller-gen correctly validates that +listType markers should only be applied to list-type fields.

Proposal:

To prevent this issue from recurring and to improve the robustness of the generated OpenAPI schemas, kube-openapi should be updated to validate the use of the +listType marker. The tool should produce an error if this marker is applied to any field that is not a slice.

This change would align the behavior of kube-openapi with controller-gen, ensuring that OpenAPI specifications for core Kubernetes types are generated with the same strictness as those for CRDs, preventing downstream tooling failures.

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