Skip to content
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 fields pointers unless they have a builtin nil value, e.g., slices and maps #17

Open
hatfieldbrian opened this issue May 3, 2023 · 0 comments

Comments

@hatfieldbrian
Copy link
Collaborator

hatfieldbrian commented May 3, 2023

The Kubernetes API Conventions Optional vs Required states:

Optional fields have the following properties:

  • They are a pointer type in the Go definition (e.g. bool *awesomeFlag) or have a built-in nil value (e.g. maps and slices).

string does not have a built-in nil value, but does have a similar empty, "", value. The Kubernetes core API implements optional strings as both non-pointers and pointers. I presume these non-pointers predate the pointer convention. PodSpec, for example, has 8 optional strings, the first 7 are non-pointers, the last 1 is a pointer.
https://github.com/kubernetes/api/blob/6c11c9e4685cc62e4ddc8d4aaa824c46150c9148/core/v1/types.go#L3353-L3360
https://github.com/kubernetes/api/blob/6c11c9e4685cc62e4ddc8d4aaa824c46150c9148/core/v1/types.go#L3379-L3385

The recipe has several fields of type string, most are probably optional and should be pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant