Skip to content

Commit 7380028

Browse files
author
ymqytw
committed
update wording and add a simple example
1 parent 843e051 commit 7380028

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

contributors/design-proposals/preserve-order-in-strategic-merge-patch.md

+23-8
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,38 @@ Ordering has semantic meaning for Environment variables,
1212
as later environment variables may reference earlier environment variables,
1313
but not the other way around.
1414

15-
An use case is the environment variables. We don't preserve the order which causes
15+
One use case is the environment variables. We don't preserve the order which causes
1616
issue [40373](https://github.com/kubernetes/kubernetes/issues/40373).
1717

1818
## Proposed Change
1919

2020
Changes are all in strategic merge patch package.
2121
The proposed solution is similar to the solution used for deleting elements from lists of primitives.
2222

23-
Add to the current patch, a directive containing a list of element keys -
23+
Add to the current patch, a directive ($setElementOrder) containing a list of element keys -
2424
either the patch merge key, or for primitives the value. When applying the patch,
25-
the server we ensure that the relative ordering of elements matches the directive.
25+
the server ensures that the relative ordering of elements matches the directive.
26+
27+
Here is an simple example:
28+
29+
Suppose we have a type called list. The patch will look like below.
30+
The order from the parallel list ($setElementOrder/list) will be respected.
31+
32+
```yaml
33+
$setElementOrder/list:
34+
- A
35+
- B
36+
list:
37+
- B
38+
- A
39+
```
2640
2741
All the items in the server's live list but not in the parallel list will be append to the end of the parallel list.
2842
The relative order between these appended items are kept.
29-
If the relative order of live config in the server is different from the order of the parallel list,
30-
user's patch will always override the order in the server.
43+
If the relative order of the live config in the server is different from the order of the parallel list,
44+
the user's patch will always override the order in the server.
3145
32-
The patched list will looks like:
46+
The patched list will look like:
3347
3448
```
3549
mergingList:
@@ -144,8 +158,9 @@ list:
144158
The new version patch is always a superset of the old version patch.
145159
The new patch has one additional parallel list which will be dropped by the old server.
146160

147-
The logic for old version patch is still kept,
148-
so the patch from any arbitrary old clients used to work before will continue to function.
161+
The new directive is optional.
162+
Patch requests without the directive will retain the behavior from previous releases.
163+
This will ensure backward compatibility with old clients.
149164

150165
This change is fully backward compatible.
151166

0 commit comments

Comments
 (0)