Update preserve-order-in-strategic-merge-patch.md
This commit is contained in:
parent
4655e294fe
commit
fd41886664
|
|
@ -7,7 +7,7 @@ Author: @mengqiy
|
||||||
Background of the Strategic Merge Patch is covered [here](../devel/strategic-merge-patch.md).
|
Background of the Strategic Merge Patch is covered [here](../devel/strategic-merge-patch.md).
|
||||||
|
|
||||||
The Kubernetes API may apply semantic meaning to the ordering of items within a list,
|
The Kubernetes API may apply semantic meaning to the ordering of items within a list,
|
||||||
however the strategic merge patch does not keeping the ordering of elements.
|
however the strategic merge patch does not keep the ordering of elements.
|
||||||
Ordering has semantic meaning for Environment variables,
|
Ordering has semantic meaning for Environment variables,
|
||||||
as later environment variables may reference earlier environment variables,
|
as later environment variables may reference earlier environment variables,
|
||||||
but not the other way around.
|
but not the other way around.
|
||||||
|
|
@ -30,7 +30,7 @@ Add to the current patch, a directive ($setElementOrder) containing a list of el
|
||||||
either the patch merge key, or for primitives the value. When applying the patch,
|
either the patch merge key, or for primitives the value. When applying the patch,
|
||||||
the server ensures that the relative ordering of elements matches the directive.
|
the server ensures that the relative ordering of elements matches the directive.
|
||||||
|
|
||||||
The server will reject the patch if it doesn't satisfy the following 2 requirement.
|
The server will reject the patch if it doesn't satisfy the following 2 requirements.
|
||||||
- the relative order of any two items in the `$setElementOrder` list
|
- the relative order of any two items in the `$setElementOrder` list
|
||||||
matches that in the patch list if they present.
|
matches that in the patch list if they present.
|
||||||
- the items in the patch list must be a subset or the same as the `$setElementOrder` list if the directive presents.
|
- the items in the patch list must be a subset or the same as the `$setElementOrder` list if the directive presents.
|
||||||
|
|
@ -45,7 +45,7 @@ The relative order of two items are determined by the following order:
|
||||||
If the relative order of the live config in the server is different from the order of the parallel list,
|
If the relative order of the live config in the server is different from the order of the parallel list,
|
||||||
the user's patch will always override the order in the server.
|
the user's patch will always override the order in the server.
|
||||||
|
|
||||||
Here is an simple example of the patch format:
|
Here is a simple example of the patch format:
|
||||||
|
|
||||||
Suppose we have a type called list. The patch will look like below.
|
Suppose we have a type called list. The patch will look like below.
|
||||||
The order from the parallel list ($setElementOrder/list) will be respected.
|
The order from the parallel list ($setElementOrder/list) will be respected.
|
||||||
|
|
@ -60,7 +60,7 @@ list:
|
||||||
- C
|
- C
|
||||||
```
|
```
|
||||||
|
|
||||||
All the items in the server's live list but not in the parallel list will be come before the parallel list.
|
All the items in the server's live list but not in the parallel list will come before the parallel list.
|
||||||
The relative order between these appended items are kept.
|
The relative order between these appended items are kept.
|
||||||
|
|
||||||
The patched list will look like:
|
The patched list will look like:
|
||||||
|
|
@ -114,7 +114,7 @@ list:
|
||||||
### `$setElementOrder` may contain elements not present in the patch list
|
### `$setElementOrder` may contain elements not present in the patch list
|
||||||
|
|
||||||
The $setElementOrder value may contain elements that are not present in the patch
|
The $setElementOrder value may contain elements that are not present in the patch
|
||||||
but present in the list to be merge to reorder the elements as part of the merge.
|
but present in the list to be merged to reorder the elements as part of the merge.
|
||||||
|
|
||||||
Example where A & B have not changed:
|
Example where A & B have not changed:
|
||||||
|
|
||||||
|
|
@ -481,15 +481,15 @@ we send a whole list from user's config.
|
||||||
It is NOT backward compatible in terms of list of primitives.
|
It is NOT backward compatible in terms of list of primitives.
|
||||||
|
|
||||||
When patching a list of maps:
|
When patching a list of maps:
|
||||||
- An old client sends a old patch to a new server, the server just merges the change and no reordering.
|
- An old client sends an old patch to a new server, the server just merges the change and no reordering.
|
||||||
The server behaves the same as before.
|
The server behaves the same as before.
|
||||||
- An new client sends a new patch to an old server, the server doesn't understand the new directive.
|
- A new client sends a new patch to an old server, the server doesn't understand the new directive.
|
||||||
So it just simply does the merge.
|
So it just simply does the merge.
|
||||||
|
|
||||||
When patching a list of primitives:
|
When patching a list of primitives:
|
||||||
- An old client sends a old patch to a new server, the server will reorder the patch list which is sublist of user's.
|
- An old client sends an old patch to a new server, the server will reorder the patch list which is sublist of user's.
|
||||||
The server has the WRONG behavior.
|
The server has the WRONG behavior.
|
||||||
- An new client sends a new patch to an old server, the server will deduplicate after merging.
|
- A new client sends a new patch to an old server, the server will deduplicate after merging.
|
||||||
The server behaves the same as before.
|
The server behaves the same as before.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue