kubernetes / kube-openapi

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

Support PostProcessSpec hook in V3 #420

Closed ryantxu closed 1 year ago

ryantxu commented 1 year ago

Currently, the PostProcessSpec hook is only called when creating v2, but does not work for V3. This PR adds an additional hook and calls it while creating the spec.

While building an agregated api-server I am able to apply my special needs to the V2 spec, but not v3. The call is initiated from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/server/routes/openapi.go#L68 so I think it makes most sense to hook in here, but also open to any other suggestions!

linux-foundation-easycla[bot] commented 1 year ago

CLA Signed

The committers listed above are authorized under a signed CLA.

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ryantxu Once this PR has been reviewed and has the lgtm label, please assign jefftree for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/kubernetes/kube-openapi/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
k8s-ci-robot commented 1 year ago

Welcome @ryantxu!

It looks like this is your first PR to kubernetes/kube-openapi 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-openapi has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

ryantxu commented 1 year ago

@Jefftree -- thoughts on what to do with this PR? I suspect changing *openapicommon.Config to Config3 (or similar) is a massive project :)

Is the approach here a reasonable path?

Jefftree commented 1 year ago

I briefly looked and it shouldn't be too hard to change to Config3. Will get to it soon

ryantxu commented 1 year ago

Closing here -- this will not be required with https://github.com/kubernetes/kubernetes/pull/121010

Thanks @Jefftree

Jefftree commented 1 year ago

@ryantxu The PR linked only decouples the OpenAPI V2 and V3 config. Parts of this PR would still be needed to support PostProcessSpec3 function right?

ryantxu commented 1 year ago

Ya -- except it would be a hook on the v3 config. I'll reopen and update. I am just not clear how to easily test/verify until the other changes are sorted