Skip to content

Make optional fields pointers unless they have a builtin nil value, e.g., slices and maps #17

@hatfieldbrian

Description

@hatfieldbrian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions