New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ feat: Add resource field-scoped fields #878
base: master
Are you sure you want to change the base?
Conversation
Welcome @TheSpiritXIII! |
Hi @TheSpiritXIII. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions 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/test-infra repository. |
c28336c
to
51a9ac8
Compare
51a9ac8
to
41f7c86
Compare
41f7c86
to
f414cc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for this one (not maintainer, but reviewed the code)
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bwplotka, TheSpiritXIII The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This feature adds resource field-scoped fields.
Why?
While working on Google Managed Service for Prometheus, we identified a need to have namespaced and cluster-scoped versions of the same structs.
How
This solution adds a new marker on fields that appear conditionally depending on the top-level CRD scope.
For example, we may have a struct:
For a namespaced CRD, the
namespace
field will not be generated as part of the OpenAPI specification because the namespace field is marked as being cluster-scoped.The opposite is true as well. A field can be marked namespaced and will not be generated for cluster-scoped resources.
Defaults apply too. A CRD is considered namespaced by default, so cluster-scoped fields will not appear.
Implementation
The implementation is admittedly a bit hacky. A special property is inserted at schema parse-time, and later removed when processing the resource. I couldn't figure out a better way to do this. The comments in the code should describe why it was done this way.