Validate listType usage on struct fields#569
Validate listType usage on struct fields#569lalitc375 wants to merge 1 commit intokubernetes:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lalitc375 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
Validate listType usage on struct fields
Fixes : #554.
kube-openapiis updated to validate the usage of the// +listTypemarker. The tool will now generate an error if this marker is applied to any field that is not a slice or an array. This change ensures that the OpenAPI specifications for core Kubernetes types are generated with the same strictness as those for CRDs, preventing downstream tooling failures.Problem:
Currently,
kube-openapiallows the// +listTypemarker to be used on fields that are not lists or slices. This can result in the generation of an invalid OpenAPI schema. For example, a+listType=atomicmarker was incorrectly applied to themetav1.Status.Detailsfield, which is a struct, not a list type. This causes tools that consume the schema, such ascontroller-gen, to fail when generating Custom Resource Definitions (CRDs) that embedmetav1.Status.Solution:
This pull request introduces a validation check in
kube-openapito ensure that the+listTypemarker is only used on slice or array fields. If the marker is used on any other type of field, an error will be returned.Unit tests have been added to verify the new validation logic, including a test case that is expected to fail when
+listTypeis used on a string field.