Fix LabelSelector validation markers for map field #1717
Merged
+5 −2
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Backport of PR #1679
Fix LabelSelector validation markers for map field
Changed MinItems/MaxItems to MinProperties/MaxProperties for the MatchLabels field in LabelSelector, as it is a map type, not an array. This resolves controller-gen CRD generation errors.
Add CRD generation to make generate target
Add controller-gen crd to the generate target to validate kubebuilder markers during development and CI runs.
Previously, make generate only ran controller-gen object, which generates DeepCopy methods but does not validate CRD markers like MinItems, MaxItems, MinProperties, etc. This meant invalid markers could be merged without detection, only to cause failures in downstream projects that run full CRD generation.
By adding CRD generation to the generate target:
This change would have caught the MinItems/MaxItems issue fixed in commit 40cecfd before it was merged.
This regenerates the CRDs to include the MinProperties/MaxProperties validation for the MatchLabels map field.
The generated CRD now includes:
These properties correctly validate the map field, replacing the incorrect MinItems/MaxItems markers that were causing controller-gen failures.
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?: