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

[WIP] Document patch strategy markers in api-conventions #4218

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions contributors/devel/sig-architecture/api-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,19 @@ saved. For more details on how to use Merge Patch, see the RFC.
detailed explanation of how it works and why it needed to be introduced, see
[here](/contributors/devel/sig-api-machinery/strategic-merge-patch.md).

#### Defining Patch Strategy
In the context of strategic merge patch, a set of go markers can be used by API authors to define the merge strategy of collections of fields (lists, maps and structs).

| Marker | Definition |
|--------|------------|
| `// +patchStrategy=merge/replace` | Defines that the merge strategy will be to merge elements of the two lists into one (merge), use the list provided in the patch literally rather than merging (replace) |
| `// +patchMergeKey=<key-name>` | This is applicable in the context of lists being used as maps/dictionaries, i.e. with each entry in the list seen as a key-value pair, with a specific field considered the key. `patchMergeKey` defines what field should be seen as the key. Combined with `patchStrategy`, this describes what changes should take place on specific elements of a list as part of a patch operation. |
| `// +listType=atomic/set/associative` | |
mariantalla marked this conversation as resolved.
Show resolved Hide resolved
| `// +mapType=separate/atomic` | |
| `// +structType=separate/atomic` | |



## Idempotency

All compatible Kubernetes APIs MUST support "name idempotency" and respond with
Expand Down