-
Notifications
You must be signed in to change notification settings - Fork 584
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
Make optional API fields consistently pointers (or not pointers) #3243
Comments
Thanks @invidian There is some inconsistency in how we represent optional fields....to pointer or not to pointer, that is the question. We have had some issues with the code gen tools in the past not liking slices of pointers to structs as well. We should some up with clear guidance and do any refactoring as required. /triage accepted |
/help |
@richardcase: GuidelinesPlease ensure that the issue body includes answers to the following questions:
For more details on the requirements of such an issue, please see here and ensure that they are met. If this request no longer meets these requirements, the label can be removed In 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. |
Just thinking out loud to help understand issue, below are the Pros and cons of using pointers: Pros:
Cons:
As long as we are not constrained about performance, goroutines(as there can be race conditions with pointers) and error handling, we can opt for using pointers in optional fields as otherwise it would become little tedious to use primitive types in some places. |
Quoting from https://cluster-api.sigs.k8s.io/contributing#optional-vs-required
As @richardcase mentioned, we are avoiding to use pointer slices, but that does not have a down side as we can still have nil checks. |
What about the primitive types field like string, int32 etc. In case we don't use pointer, suppose for int32 field how would w know if it is 0 or is not set in JSON response ? |
For the rest, pointers are suggested in Kubernetes API conventions doc: |
@sedefsavas Then I totally agree with what you suggested here. |
Just a note, when addressing the feedback in #2271, I've noticed that after making field a pointer type in |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Should we do this as part of the v1beta2 version bump (#2355)? @sedefsavas @Ankitasw @Skarlso - wdyt? |
Can we do it following the v1beta2 changes? It wont break anything right, since anyways we are not doing any release with v1beta2 as of now? Please correct me if I am wrong. |
Yeah, let's do this after. That PR is huge already anyways... And I have another issue that's waiting for an updated API to take care off. :D |
This is still missed 😢 I am not sure if we would be able to make it in v2.0.0? |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/kind feature
Describe the solution you'd like
As discussed in #2271 (comment), some API fields marked as optional are value fields, not pointers, others are pointers. Perhaps this should be unified at some point.
The text was updated successfully, but these errors were encountered: