Skip to content

Commit

Permalink
Merge pull request #5782 from sbueringer/pr-api-conventions-struct-po…
Browse files Browse the repository at this point in the history
…inter

📖 API conventions: add note about when struct fields should be pointer
  • Loading branch information
k8s-ci-robot authored Dec 10, 2021
2 parents 86cb340 + 48099aa commit 801e6a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,11 @@ This project follows the [Kubernetes API conventions](https://github.com/kuberne

Optional fields have the following properties:
* An optional field MUST be marked with `+optional` and include an `omitempty` JSON tag.
* Fields SHOULD be pointers if the nil and the zero values (by Go standards) have semantic differences.
* Note: This doesn't apply to map or slice types as they are assignable to `nil`.
* Fields SHOULD be pointers if there is a good reason for it, for example:
* the nil and the zero values (by Go standards) have semantic differences.
* Note: This doesn't apply to map or slice types as they are assignable to `nil`.
* the field is of a struct type, contains only fields with `omitempty` and you want
to prevent that it shows up as an empty object after marshalling (e.g. `kubectl get`)

#### Example

Expand Down

0 comments on commit 801e6a7

Please sign in to comment.