Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: detiber 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 |
|
@sttts I ran into this issue when trying to add Namespaces support to my minimal apiserver implementation, I used the changes here to generate the defaults used here: https://github.com/thetirefire/badidea/pull/12/files#diff-a80ecef7b7a6df7985c380dd10060f26 |
|
Why would you want defaults for external types? |
|
@sttts In the current case I'm trying to re-implement support for namespaces in thetirefire/badidea#12, but we've also hit similar types of issues with Cluster API when trying to expose kubeadm config types. Since the defaults (and validations) apply to the public types, it makes sense to either be able to import and/or generate them for various reasons in external projects. |
|
I am not convinced this is needed. Please add an example (as simple as possible) to the /hold |
|
@lavalamp I'm not sure the defaulting changes (at least the ones in https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1929-built-in-default and the related changes in https://github.com/kubernetes/enhancements/pull/2082/files) would resolve the issue. Basically, since the defaulting logic is not defined as part of k8s.io/api, if I'm trying to re-use those types fully (not embedding within another type or CRD), there is no current way for me to use the same defaulting as k/k (without also importing k/k). Currently the generated defaults in k/k are generated using hardcoded paths to the external types defined in the staging repository. While I suppose it would be possible to also introduce a similar staging directory and generate the defaulting logic the same way it is done in k/k, however that also comes with all the same downsides. By allowing defaulter-gen to reference external types, it would also benefit a potential future k/k that leverages go modules without a staging directory. Alternatively, I would love it if the defaulting logic was in k8s.io/api, since that would also allow for easier use in other places (such as client side code), but that does present more complications for updating or changing defaults. |
|
@detiber you have k/api vendored. Why not just reference the vendored copy?
I don't follow here. We do exactly that: k/pkg/apis/apps/v1/doc.go: It references external types. What is different in your use-case (other than that |
To clarify: defaulting is always operating on external types. But defaulting is something we don't want non-apiservers to consume. Hence, we have it in |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
@detiber: PR needs rebase. 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/test-infra repository. |
|
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
|
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
|
@fejta-bot: Closed this PR. DetailsIn response to this:
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. |
Adds support for generating defaults for external types, similar to what conversion-gen does.