kubernetes / kube-openapi

Kubernetes OpenAPI spec generation & serving
Apache License 2.0
319 stars 208 forks source link

validate: Expose hooks to inject custom behavior during traversal #406

Closed alexzielenski closed 1 year ago

alexzielenski commented 1 year ago

Adds a new Option to the schema validator for users to provider custom constructors for subfield and subindex-validators created during traversal.

/cc @stts @apelisse @jpbetz

k8s-ci-robot commented 1 year ago

@alexzielenski: GitHub didn't allow me to request PR reviews from the following users: stts.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to [this](https://github.com/kubernetes/kube-openapi/pull/406): >Proof of concept that adds a ratcheting validator to kube-openapi. Taking care to change code as minimally as possible. > >More complicated/expansive tests forthcoming. > >Ignores allOf, anyOf, not, oneOf for the purposes of ratcheting. > >Still need to evaluate proper handling of `required`/`dependentProperties` and other cases which may not be caught by current `DeepEqual`. > >/cc @stts @apelisse @jpbetz Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
alexzielenski commented 1 year ago

/cc @sttts

apelisse commented 1 year ago

Looks good to me, Stefan, can you tag it? /approve

jpbetz commented 1 year ago

/approve

I'll defer to @sttts for lgtm

sttts commented 1 year ago

Lgtm with exception of https://github.com/kubernetes/kube-openapi/pull/406/files#r1263940329.

alexzielenski commented 1 year ago

removed string slice logic

alexzielenski commented 1 year ago

/label tide/merge-method-squash

sttts commented 1 year ago

/lgtm /approve

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexzielenski, apelisse, jpbetz, sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[pkg/validation/OWNERS](https://github.com/kubernetes/kube-openapi/blob/master/pkg/validation/OWNERS)~~ [sttts] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment