[Declarative Validation] Add k8s-cidr format to +k8s:format tag#138201
[Declarative Validation] Add k8s-cidr format to +k8s:format tag#138201sAchin-680 wants to merge 4 commits into
Conversation
Add a new +k8s:maxProperties=<N> declarative validation tag that enforces a maximum number of entries in a map field. This corresponds to the OpenAPI/JSON Schema maxProperties keyword. Changes: - Add MaxProperties[K comparable, V any] runtime validation function to k8s.io/apimachinery/pkg/api/validate with 'maxProperties' origin. - Add TestMaxProperties to limits_test.go covering 0/1/2-item maps and negative max boundary cases. - Add maxPropertiesTagValidator to validation-gen validators/limits.go: - Restricted to map types only (mirrors +k8s:maxItems for slices) - Uses ShortCircuit flag to prevent DoS via oversized-map validation - Parses value via util.ParseInt, rejects negative values - Stability level: Alpha - Annotate StorageClass.Parameters with +k8s:maxProperties=512 as the first consumer, replacing the hand-written len(params) > 512 guard. - Add CHANGELOG entry. Fixes: kubernetes#138112 Signed-off-by: sAchin-680 <mrmister680@gmail.com>
…to +k8s:format DV tag Implements kubernetes#138113. Adds CIDRSloppy, CIDRv4Sloppy, CIDRv6Sloppy validators in k8s.io/apimachinery/pkg/api/validate using netutils.ParseCIDRSloppy for backwards-compatible (sloppy) CIDR parsing that tolerates leading zeros and interface-address-form CIDRs. Registers k8s-cidr, k8s-cidrv4, and k8s-cidrv6 in the +k8s:format declarative validation tag switch in the validation-gen code generator. Output integration tests are added for all three new format values following the same pattern as existing format output tests. Signed-off-by: sAchin-680 <mrmister680@gmail.com>
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Hi @sAchin-680. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sAchin-680 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 |
|
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
|
Adding label DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds three new format values to the
+k8s:formatdeclarative validation tag:k8s-cidr,k8s-cidrv4, andk8s-cidrv6.These use sloppy CIDR parsing (
netutils.ParseCIDRSloppy) to match historical Kubernetes behavior — tolerating leading zeros in IPv4 octets and interface-address–form CIDRs (e.g.192.168.1.5/24). Thev4andv6variants additionally enforce address-family.Three runtime functions are added to
k8s.io/apimachinery/pkg/api/validate:CIDRSloppy,CIDRv4Sloppy, andCIDRv6Sloppy. Output integration tests follow the same pattern as all existing format output tests.Which issue(s) this PR is related to:
Fixes: #138113
Special notes for your reviewer:
k8s-ipformat is still commented out informat.godue to ratcheting concerns; that decision is unaffected by this PR.output_tests/tags/format/k8s-cidr{,v4,v6}/and are structured identically tok8s-uuid,k8s-label-key, etc.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: