Commit 82245a1f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #45980 from mengqiy/setElementOrder

Automatic merge from submit-queue support setElementOrder Implement [proposal](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/preserve-order-in-strategic-merge-patch.md). Fixes #40373 ```release-note kubectl edit and kubectl apply will keep the ordering of elements in merged lists ```
parents d3554ac0 c3481b07
{ {
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 82
"port": 81 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 82, "port": 82,
"protocol": "TCP", "protocol": "TCP",
"targetPort": 80 "targetPort": 80
},
{
"$patch": "delete",
"port": 81
} }
] ]
} }
......
{ {
"spec": { "spec": {
"$setElementOrder/ports": [
{
"port": 82
}
],
"clusterIP": "10.0.0.10", "clusterIP": "10.0.0.10",
"ports": [ "ports": [
{ {
......
...@@ -5,16 +5,21 @@ ...@@ -5,16 +5,21 @@
} }
}, },
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 83
"port": 82 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 83, "port": 83,
"protocol": "VHF", "protocol": "VHF",
"targetPort": 81 "targetPort": 81
},
{
"$patch": "delete",
"port": 82
} }
] ]
} }
......
...@@ -5,16 +5,21 @@ ...@@ -5,16 +5,21 @@
} }
}, },
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 83
"port": 82 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 83, "port": 83,
"protocol": "TCP", "protocol": "TCP",
"targetPort": 81 "targetPort": 81
},
{
"$patch": "delete",
"port": 82
} }
] ]
} }
......
...@@ -8,16 +8,21 @@ ...@@ -8,16 +8,21 @@
} }
}, },
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 82
"port": 81 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 82, "port": 82,
"protocol": "TCP", "protocol": "TCP",
"targetPort": 81 "targetPort": 81
},
{
"$patch": "delete",
"port": 81
} }
] ]
} }
......
...@@ -5,16 +5,21 @@ ...@@ -5,16 +5,21 @@
} }
}, },
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 82
"port": 81 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 82, "port": 82,
"protocol": "TCP", "protocol": "TCP",
"targetPort": 81 "targetPort": 81
},
{
"$patch": "delete",
"port": 81
} }
] ]
} }
......
{ {
"metadata": { "metadata": {
"labels": { "labels": {
"new-label": "new-value" "new-label": "new-value"
} }
} }
} }
\ No newline at end of file
...@@ -5,16 +5,21 @@ ...@@ -5,16 +5,21 @@
} }
}, },
"spec": { "spec": {
"ports": [ "$setElementOrder/ports": [
{ {
"$patch": "delete", "port": 81
"port": 80 }
}, ],
"ports": [
{ {
"name": "80", "name": "80",
"port": 81, "port": 81,
"protocol": "TCP", "protocol": "TCP",
"targetPort": 80 "targetPort": 80
},
{
"$patch": "delete",
"port": 80
} }
] ]
} }
......
{ {
"metadata": { "metadata": {
"annotations": { "annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":\"2017-02-27T19:40:53Z\",\"labels\":{\"app\":\"svc1\",\"new-label\":\"new-value\"},\"name\":\"svc1\",\"namespace\":\"edit-test\",\"resourceVersion\":\"670\",\"selfLink\":\"/api/v1/namespaces/edit-test/services/svc1\",\"uid\":\"a6c11186-fd24-11e6-b53c-480fcf4a5275\"},\"spec\":{\"clusterIP\":\"10.0.0.204\",\"ports\":[{\"name\":\"80\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":80}],\"selector\":{\"app\":\"svc1\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}\n" "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":\"2017-02-27T19:40:53Z\",\"labels\":{\"app\":\"svc1\",\"new-label\":\"new-value\"},\"name\":\"svc1\",\"namespace\":\"edit-test\",\"resourceVersion\":\"670\",\"selfLink\":\"/api/v1/namespaces/edit-test/services/svc1\",\"uid\":\"a6c11186-fd24-11e6-b53c-480fcf4a5275\"},\"spec\":{\"clusterIP\":\"10.0.0.204\",\"ports\":[{\"name\":\"80\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":80}],\"selector\":{\"app\":\"svc1\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}\n"
}, },
"labels": { "labels": {
"new-label": "new-value" "new-label": "new-value"
} }
} }
} }
\ No newline at end of file
...@@ -23,11 +23,12 @@ import ( ...@@ -23,11 +23,12 @@ import (
) )
var ( var (
ErrBadJSONDoc = errors.New("invalid JSON document") ErrBadJSONDoc = errors.New("invalid JSON document")
ErrNoListOfLists = errors.New("lists of lists are not supported") ErrNoListOfLists = errors.New("lists of lists are not supported")
ErrBadPatchFormatForPrimitiveList = errors.New("invalid patch format of primitive list") ErrBadPatchFormatForPrimitiveList = errors.New("invalid patch format of primitive list")
ErrBadPatchFormatForRetainKeys = errors.New("invalid patch format of retainKeys") ErrBadPatchFormatForRetainKeys = errors.New("invalid patch format of retainKeys")
ErrPatchContentNotMatchRetainKeys = errors.New("patch content doesn't match retainKeys list") ErrBadPatchFormatForSetElementOrderList = errors.New("invalid patch format of setElementOrder list")
ErrPatchContentNotMatchRetainKeys = errors.New("patch content doesn't match retainKeys list")
) )
func ErrNoMergeKey(m map[string]interface{}, k string) error { func ErrNoMergeKey(m map[string]interface{}, k string) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment